Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.

rliang/compick.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

compick.vim

A completion-based general-purpose picker for vim

What

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.

Quickstart

nnoremap <leader>foo :call compick#do('mru')<cr>
nnoremap <leader>bar :call compick#do('cwd')<cr>
nnoremap <leader>baz :call compick#do('git')<cr>

Buffer-local variables

  • 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's word and does something. Default
  • b: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. Default
  • b: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

Functions

  • compick#do(type[,split]): Opens a picker buffer of filetype compick-<type> in the given split (default bottom 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 in lines.

Default mappings

  • <cr>: Complete the current match and run the buffer action for each line;
  • <esc>: Quit.

Customizing a picker type

au FileType compick-* setlocal noshowmode
au FileType compick-cwd ino <buffer><c-u> <esc>:call compick#accept(['..'])<cr>

Defining a picker type

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.

About

A completion-based general-purpose picker for vim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published