neoclide / coc-lists

Common lists for coc.nvim
264 stars 24 forks source link
coc list neovim vim

coc-lists

Some basic list sources for coc.nvim

Including:

For snippets list, use coc-snippets.

For git related list, use coc-git.

For yank history, use coc-yank.

Install

In your vim/neovim, run command:

:CocInstall coc-lists

Checkout :h coc-list for usage.

Options

Tip: type ? on normal mode to get detail help of current list.

Available options for coc-lists:

Commands

F.A.Q

Q: Hidden files not exists using files source.

A: You have to pass --hidden to ripgrep by using configuration:

`list.source.files.args`: ['--hidden', '--files']

Q: How to ignore files using files/grep source.

A: You can add .ignore file in your project root, which would be respected by ripgrep or use list.sourcefiles.excludePatterns configuration.

Q: How to make grep easier?

A: Create custom command like:

" grep word under cursor
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")
endfunction

" Keymapping for grep word under cursor with interactive mode
nnoremap <silent> <Leader>cf :exe 'CocList -I --input='.expand('<cword>').' grep'<CR>

Q: 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
endfunction

Q: 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>

Q: How to grep word in a specific folder?

A: Pass -- /folder/to/search/from to CocList grep

:CocList grep word -- /folder/to/search/from

License

MIT