Add :BMarks command (#1593)

And allow passing arguments of :marks to :Marks command. Close #1158.

Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
This commit is contained in:
Scott Lai
2025-06-07 18:48:17 -07:00
committed by GitHub
parent 3ed6ac56d0
commit a2ed9fb885
4 changed files with 21 additions and 8 deletions

View File

@@ -1362,15 +1362,25 @@ function! s:mark_sink(lines)
execute 'normal! `'.matchstr(a:lines[1], '\S').'zz'
endfunction
function! fzf#vim#marks(...)
function! fzf#vim#marks(...) abort
let [initial_marks, extra] = (a:0 && type(a:1) == type('')) ?
\ [a:1, a:000[1:]] : ['', a:000]
redir => cout
silent marks
execute 'silent! marks' initial_marks
redir END
let list = split(cout, "\n")
" If first line is not the expected header, no marks found
if empty(list) || list[0] =~# '^E'
return s:warn('No marks found')
endif
return s:fzf('marks', {
\ 'source': extend(list[0:0], map(list[1:], 's:format_mark(v:val)')),
\ 'source': extend(list[0:0], map(list[1:], 's:format_mark(v:val)')),
\ 'sink*': s:function('s:mark_sink'),
\ 'options': '+m -x --ansi --tiebreak=index --header-lines 1 --tiebreak=begin --prompt "Marks> "'}, a:000)
\ 'options': '+m -x --ansi --tiebreak=index --header-lines 1 --tiebreak=begin --prompt "Marks> "'}, extra)
endfunction
" ------------------------------------------------------------------