tessl install tessl/npm-coc-nvim@0.0.0LSP based intellisense engine for neovim & vim8.
Complexity: Intermediate | Category: UI
Common Tasks: Open lists | Search files | Navigate diagnostics | Browse symbols
Fuzzy finder interface for navigating files, symbols, diagnostics, and more with interactive filtering and actions.
:CocList filesBrowse and open files in workspace.
:CocList diagnosticsNavigate all diagnostics across buffers.
:CocList symbolsSearch workspace symbols.
:CocListResumeReopen previous list session.
:CocList [options] {source} [args...]Open coc list with specified source.
Options:
--normal: Start in normal mode instead of insert mode--no-sort: Disable sorting--input=<text>: Set initial input text--strict: Use strict matching instead of fuzzy--regex: Use regex matching--ignore-case: Case insensitive matching--number-select: Enable number select mode--auto-preview: Enable auto preview--interactive: Interactive mode--top: Show list at top--tab: Open in new tab--first: Select first item on startExample:
:CocList files
:CocList --normal diagnostics
:CocList --input=test symbols
:CocList grep TODO:CocListResume [name]Resume previous list session.
Parameters:
name: Optional list name to resume specific listExample:
:CocListResume
:CocListResume files:CocListCancelCancel active list.
Example:
:CocListCancel:CocPrev [name]Navigate to previous item in list history.
Parameters:
name: Optional list nameExample:
:CocPrev
:CocPrev diagnostics:CocNext [name]Navigate to next item in list history.
Parameters:
name: Optional list nameExample:
:CocNext
:CocNext location:CocFirst [name]Jump to first item in list history.
Parameters:
name: Optional list nameExample:
:CocFirst:CocLast [name]Jump to last item in list history.
Parameters:
name: Optional list nameExample:
:CocLast:CocList actionsList available code actions for current location.
:CocList commandsList all coc commands.
:CocList diagnosticsList all diagnostics from all buffers.
:CocList extensionsList installed extensions with management actions.
:CocList foldersList workspace folders.
:CocList listsList available list sources.
:CocList locationList items from last location list.
:CocList outlineList document symbols as outline.
:CocList outputList output channels.
:CocList servicesList language services.
:CocList sourcesList completion sources.
:CocList symbols [query]List workspace symbols with optional search query.
coc#list#names(...)
" Returns: stringGet list of available list names for completion.
Returns: Space-separated string of list names.
coc#list#options(...)
" Returns: stringGet list options for completion.
Returns: Space-separated string of options.
coc#list#status(name)
" Returns: stringGet status string for a list.
Parameters:
name: List nameReturns: Status string.
coc#list#has_preview()
" Returns: booleanCheck if preview window exists.
Returns: 1 if preview exists, 0 otherwise.
coc#list#get_preview(...)
" Returns: dictionaryGet preview window information.
Returns: Dictionary with preview window details.
coc#list#scroll_preview(dir)Scroll preview window.
Parameters:
dir: Direction ('up' or 'down')Example:
call coc#list#scroll_preview('down')coc#list#close_preview(tabnr)Close preview window.
Parameters:
tabnr: Tab numbercoc#list#getchar()
" Returns: stringGet a single character input from the user during list interaction.
Returns: Single character as string.
coc#list#setlines(bufnr, lines, append)Set buffer content with lines. Can append or replace existing content.
Parameters:
bufnr: Buffer numberlines: Array of lines to setappend: Boolean (1=append, 0=replace all)Example:
" Replace buffer content
call coc#list#setlines(bufnr, ['New line 1', 'New line 2'], 0)
" Append to buffer
call coc#list#setlines(bufnr, ['Additional line'], 1)coc#list#select(bufnr, line)Place selection sign on specified line in list buffer.
Parameters:
bufnr: Buffer numberline: Line number to select (0 to clear selection)Example:
" Select line 5
call coc#list#select(bufnr, 5)
" Clear selection
call coc#list#select(bufnr, 0)coc#list#clean_up()Close all list windows by buffer name pattern matching 'list://'.
Example:
" Close all list windows
call coc#list#clean_up()List settings in coc-settings.json:
{
"list.indicator": ">",
"list.maxHeight": 12,
"list.maxPreviewHeight": 12,
"list.selectedSignText": "*",
"list.insertMappings": {
"<C-n>": "normal:j",
"<C-p>": "normal:k",
"<C-j>": "preview:down",
"<C-k>": "preview:up"
},
"list.normalMappings": {
"<C-c>": "do:exit",
"q": "do:exit"
},
"list.previousKeymap": "<C-p>",
"list.nextKeymap": "<C-n>",
"list.autoResize": true,
"list.interactiveDebounceTime": 100
}CocListLineCurrent selected list line.
CocListSearchMatched characters in list.
CocListModeMode indicator text.
CocListPathFile path in list items.
CocSelectedTextSign for selected text.
CocSelectedLineSelected line highlight.
" Open file list
nnoremap <silent> <leader>ff :CocList files<CR>
" Open diagnostics list
nnoremap <silent> <leader>fd :CocList diagnostics<CR>
" Open symbols list
nnoremap <silent> <leader>fs :CocList symbols<CR>
" Resume last list
nnoremap <silent> <leader>fr :CocListResume<CR>" Previous/next in list history
nnoremap <silent> [l :CocPrev<CR>
nnoremap <silent> ]l :CocNext<CR>
" First/last
nnoremap <silent> [L :CocFirst<CR>
nnoremap <silent> ]L :CocLast<CR>" Files with normal mode and preview
nnoremap <silent> <leader>fp :CocList --normal --auto-preview files<CR>
" Diagnostics with initial filter
nnoremap <silent> <leader>de :CocList --input=error diagnostics<CR>
" Symbols with number select
nnoremap <silent> <leader>sn :CocList --number-select symbols<CR>" Add custom list mappings in coc-settings.json
{
"list.insertMappings": {
"<C-v>": "action:vsplit",
"<C-s>": "action:split",
"<C-t>": "action:tabe",
"<C-d>": "preview:down",
"<C-u>": "preview:up"
},
"list.normalMappings": {
"v": "action:vsplit",
"s": "action:split",
"t": "action:tabe",
"d": "do:delete"
}
}function! PreviewList(source) abort
execute 'CocList --normal --auto-preview ' . a:source
endfunction
nnoremap <silent> <leader>lp :call PreviewList('files')<CR>" Grep for pattern
nnoremap <leader>fg :CocList grep<CR>
" Grep for word under cursor
nnoremap <silent> <leader>fw :exe 'CocList --input='.expand('<cword>').' grep'<CR>
" Grep in specific directory
nnoremap <leader>fgd :CocList grep -cwd /path/to/dir<CR>" Interactive diagnostics
nnoremap <silent> <leader>di :CocList --interactive diagnostics<CR>
" Interactive symbols
nnoremap <silent> <leader>si :CocList --interactive symbols<CR>function! ShowListStatus(name) abort
let status = coc#list#status(a:name)
if !empty(status)
echo status
else
echo 'No status for list: ' . a:name
endif
endfunction
command! -nargs=1 ListStatus call ShowListStatus(<q-args>)" Scroll preview in list
function! ListPreviewDown() abort
if coc#list#has_preview()
call coc#list#scroll_preview('down')
endif
endfunction
function! ListPreviewUp() abort
if coc#list#has_preview()
call coc#list#scroll_preview('up')
endif
endfunction
" Map in list mode (add to insertMappings/normalMappings)function! ShowAvailableLists() abort
execute 'CocList lists'
endfunction
command! Lists call ShowAvailableLists()" Jump through location list with CocList
function! LocationListNext() abort
try
CocNext location
catch
echo 'No more items'
endtry
endfunction
function! LocationListPrev() abort
try
CocPrev location
catch
echo 'No previous items'
endtry
endfunction
nnoremap <silent> ]q :call LocationListNext()<CR>
nnoremap <silent> [q :call LocationListPrev()<CR>" Example: Create custom list workflow
function! MyCustomListWorkflow() abort
" First show diagnostics
CocList diagnostics
" User selects and fixes
" Then show symbols
CocList symbols
" User navigates
endfunction
command! CustomWorkflow call MyCustomListWorkflow()function! FilteredList(source, filter) abort
execute 'CocList --input=' . a:filter . ' ' . a:source
endfunction
command! -nargs=+ FilterList call FilteredList(<f-args>)
" Usage: :FilterList files testfunction! ListDiagnostics(severity) abort
if a:severity ==# 'error'
CocList --input=Error diagnostics
elseif a:severity ==# 'warning'
CocList --input=Warning diagnostics
else
CocList diagnostics
endif
endfunction
nnoremap <silent> <leader>de :call ListDiagnostics('error')<CR>
nnoremap <silent> <leader>dw :call ListDiagnostics('warning')<CR>" Quick access to common lists
nnoremap <silent> <C-p> :CocList files<CR>
nnoremap <silent> <C-b> :CocList buffers<CR>
nnoremap <silent> <C-g> :CocList grep<CR>
nnoremap <silent> <C-o> :CocList outline<CR>Handle cases where list source doesn't exist:
try
CocList mylist
catch
echohl Error
echo "List source 'mylist' not found"
echohl None
endtryCheck if list has items before navigation:
function! SafeListNext() abort
try
CocNext
catch /no more/
echo "Already at last item"
endtry
endfunctionVerify preview exists before operations:
if coc#list#has_preview()
call coc#list#scroll_preview('down')
else
echo "No preview window available"
endif:CocInfo:CocList lists:messages--regex or --strict options for different matchinglist.interactiveDebounceTime in settings--auto-preview flaglist.maxPreviewHeight settinglist.insertMappings and list.normalMappings in settings:verbose map <key> to check mapping--interactive mode for better performance--number-select--input= option