Some basic list sources for coc.nvim
Including:
-
filessearch files from current cwd. -
mrumost recent used files. -
grepgrep text from current cwd. -
wordssearch word in current buffer. -
locationlistitems from vim's location list. -
quickfixitems from vim's quickfix list. -
bufferscurrent buffer list. -
helptagshelptags of vim. -
tagssearch tag files. -
filetypesfile types. -
colorscolors schemes. -
marksmarks of vim. -
windowswindows of vim. -
vimcommandsavailable vim commands. -
mapskey mappings. -
cmdhistoryhistory of commands. -
searchhistoryhistory of search.
For snippets list, use coc-snippets.
For git related list, use coc-git.
For yank history, use coc-yank.
- Match for filename would be prefered.
- Match for start character of path segment would be prefered.
- Files are sorted by mru when score is same.
- Grep source use literal string by default.
In your vim/neovim, run command:
:CocInstall coc-lists
Tip: type ? on normal mode to get detail help of current list.
Available options for coc-lists:
-
"lists.disabledLists":~
List names to disable form load., default: `[]` -
"list.source.files.command":~
Command used for search for files, default: `""` -
"list.source.files.args":~
Arguments for search command, default: `[]` -
"list.source.files.excludePatterns":~
Minimatch patterns that should be excluded., default: `[]` -
"list.source.mru.maxLength":~
Max length of mru list., default: `1000` -
"list.source.mru.ignoreGitIgnore":~
Ignore git ignored files., default: `false` -
"list.source.mru.excludePatterns":~
Minimatch patterns that should be excluded., default: `["**/.git/*","/tmp/*"]` -
"list.source.grep.useLiteral":~
Use literal match unless specified regex options, default: true., default: `true` -
"list.source.grep.command":~
Command used for grep, default to 'rg'., default: `"rg"` Valid options: ["rg","ag"] -
"list.source.tags.command":~
Command used for generate tags., default: `"ctags -R ."` -
"list.source.grep.args":~
Arguments for grep command, always used for grep, default: `[]` -
"list.source.grep.excludePatterns":~
Minimatch patterns of files that should be excluded, use .ignore file is recommended., default: `[]`
mru.validateremove none exists files from mru list.tags.generategenerate tags of current project (in current cwd).
Q: How to make grep easier?
A: Create custom command like:
command! -nargs=+ -complete=custom,s:GrepArgs Rg exe 'CocList grep '.<q-args>
function! s:GrepArgs(...)
let list = ['-S', '-smartcase', '-i', '-ignorecase', '-w', '-word',
\ '-e', '-regex', '-u', '-skip-vcs-ignores', '-t', '-extension']
return join(list, "\n")
endfunctionQ: How to grep by motion?
A: Create custom keymappings like:
vnoremap <leader>g :<C-u>call <SID>GrepFromSelected(visualmode())<CR>
nnoremap <leader>g :<C-u>set operatorfunc=<SID>GrepFromSelected<CR>g@
function! s:GrepFromSelected(type)
let saved_unnamed_register = @@
if a:type ==# 'v'
normal! `<v`>y
elseif a:type ==# 'char'
normal! `[v`]y
else
return
endif
let word = substitute(@@, '\n$', '', 'g')
let word = escape(word, '| ')
let @@ = saved_unnamed_register
execute 'CocList grep '.word
endfunctionQ: How to grep current word in current buffer?
A: Create kep-mapping like:
nnoremap <silent> <space>w :exe 'CocList -I --normal --input='.expand('<cword>').' words'<CR>MIT