A completion-based general-purpose picker for vim
This plugin is yet another finder like Denite or FZF, with the following features:
- Leverages vim's built-in completion UI for choosing results;
- Easy customization:
au FileType compick-<type> let b:compick_...
; - Very small.
nnoremap <leader>foo :call compick#do('mru')<cr>
nnoremap <leader>bar :call compick#do('cwd')<cr>
nnoremap <leader>baz :call compick#do('git')<cr>
b:compick_source
: List of strings or completion items to pick from. See:h complete-items
. Default[]
.b:compick_action
: Function name or funcref that takes the picked completion item'sword
and does something. Defaultb:compick_filter
: Function name or funcref that takes the completion items and the current line, and returns the filtered items. Here you might want to use a custom fuzzy matching function. Defaultb:compick_format
: Function name or funcref that takes a completion item's index and value, and returns a completion item. Used for styling completion items. Default
compick#do(type[,split])
: Opens a picker buffer of filetypecompick-<type>
in the given split (defaultbottom 1 split
).compick#popup()
: Opens the completion popup window with the buffer's source.compick#accept(lines)
: Calls the buffer's set action with each string inlines
.
<cr>
: Complete the current match and run the buffer action for each line;<esc>
: Quit.
au FileType compick-* setlocal noshowmode
au FileType compick-cwd ino <buffer><c-u> <esc>:call compick#accept(['..'])<cr>
au FileType compick-buf let b:compick_source=map(filter(range(1,bufnr('$')),'bufloaded(v:val) && buflisted(v:val)'),'{"word":v:val,"abbr":v:val.':'.bufname(v:val)}')
au FileType compick-buf let b:compick_action={word->execute('b '.word)}
nnoremap <leader>b :call compick#do('buf')<cr>
See also the built-in types.