mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-01-21 02:22:14 +08:00
Add Marks command
This commit is contained in:
@@ -37,6 +37,7 @@ Commands
|
||||
| `Colors` | Color schemes |
|
||||
| `Ag [PATTERN]` | [ag][ag] search result (`CTRL-A` to select all, `CTRL-D` to deselect all) |
|
||||
| `Lines` | Lines in loaded buffers |
|
||||
| `Marks` | Marks |
|
||||
| `Tags` | Tags in the project (`ctags -R`) |
|
||||
| `BTags` | Tags in the current buffer |
|
||||
| `Locate PATTERN` | `locate` command output |
|
||||
|
||||
@@ -400,6 +400,37 @@ endfunction
|
||||
|
||||
command! -bang Commands call s:commands(<bang>0)
|
||||
|
||||
" ------------------------------------------------------------------
|
||||
" Marks
|
||||
" ------------------------------------------------------------------
|
||||
function! s:format_mark(line)
|
||||
return substitute(a:line, '\S', '\=s:yellow(submatch(0), 1)', '')
|
||||
endfunction
|
||||
|
||||
function! s:mark_sink(lines)
|
||||
if len(a:lines) < 2
|
||||
return
|
||||
endif
|
||||
let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
|
||||
if !empty(cmd)
|
||||
execute 'silent' cmd
|
||||
endif
|
||||
execute 'normal! `'.matchstr(a:lines[1], '\S').'zz'
|
||||
endfunction
|
||||
|
||||
function! s:marks(bang)
|
||||
redir => cout
|
||||
silent marks
|
||||
redir END
|
||||
let list = split(cout, "\n")
|
||||
call s:fzf({
|
||||
\ 'source': extend(list[0:0], map(list[1:], 's:format_mark(v:val)')),
|
||||
\ 'sink*': function('s:mark_sink'),
|
||||
\ 'options': '+m --ansi --header-lines 1 --tiebreak=begin --prompt "Marks> "'.s:expect()}, a:bang)
|
||||
endfunction
|
||||
|
||||
command! -bang Marks call s:marks(<bang>0)
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" Completion helper
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user