or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/coc.nvim@0.0.x

docs

index.md
tile.json

tessl/npm-coc-nvim

tessl install tessl/npm-coc-nvim@0.0.0

LSP based intellisense engine for neovim & vim8.

list-interface.mddocs/ui/

List Interface [Intermediate]

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.

Table of Contents

  • Common Tasks
  • Commands
  • List Sources
  • List Functions
  • Configuration
  • Highlight Groups
  • Usage Examples
  • Error Handling
  • Troubleshooting
  • See Also

Common Tasks

Open File List

:CocList files

Browse and open files in workspace.

Search Diagnostics

:CocList diagnostics

Navigate all diagnostics across buffers.

Browse Symbols

:CocList symbols

Search workspace symbols.

Resume Last List

:CocListResume

Reopen previous list session.

Commands

:CocList

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

Example:

:CocList files
:CocList --normal diagnostics
:CocList --input=test symbols
:CocList grep TODO

:CocListResume

:CocListResume [name]

Resume previous list session.

Parameters:

  • name: Optional list name to resume specific list

Example:

:CocListResume
:CocListResume files

:CocListCancel

:CocListCancel

Cancel active list.

Example:

:CocListCancel

:CocPrev

:CocPrev [name]

Navigate to previous item in list history.

Parameters:

  • name: Optional list name

Example:

:CocPrev
:CocPrev diagnostics

:CocNext

:CocNext [name]

Navigate to next item in list history.

Parameters:

  • name: Optional list name

Example:

:CocNext
:CocNext location

:CocFirst

:CocFirst [name]

Jump to first item in list history.

Parameters:

  • name: Optional list name

Example:

:CocFirst

:CocLast

:CocLast [name]

Jump to last item in list history.

Parameters:

  • name: Optional list name

Example:

:CocLast

List Sources

actions

:CocList actions

List available code actions for current location.

commands

:CocList commands

List all coc commands.

diagnostics

:CocList diagnostics

List all diagnostics from all buffers.

extensions

:CocList extensions

List installed extensions with management actions.

folders

:CocList folders

List workspace folders.

lists

:CocList lists

List available list sources.

location

:CocList location

List items from last location list.

outline

:CocList outline

List document symbols as outline.

output

:CocList output

List output channels.

services

:CocList services

List language services.

sources

:CocList sources

List completion sources.

symbols

:CocList symbols [query]

List workspace symbols with optional search query.

List Functions

coc#list#names()

coc#list#names(...)
" Returns: string

Get list of available list names for completion.

Returns: Space-separated string of list names.

coc#list#options()

coc#list#options(...)
" Returns: string

Get list options for completion.

Returns: Space-separated string of options.

coc#list#status()

coc#list#status(name)
" Returns: string

Get status string for a list.

Parameters:

  • name: List name

Returns: Status string.

coc#list#has_preview()

coc#list#has_preview()
" Returns: boolean

Check if preview window exists.

Returns: 1 if preview exists, 0 otherwise.

coc#list#get_preview()

coc#list#get_preview(...)
" Returns: dictionary

Get preview window information.

Returns: Dictionary with preview window details.

coc#list#scroll_preview()

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()

coc#list#close_preview(tabnr)

Close preview window.

Parameters:

  • tabnr: Tab number

coc#list#getchar()

coc#list#getchar()
" Returns: string

Get a single character input from the user during list interaction.

Returns: Single character as string.

coc#list#setlines()

coc#list#setlines(bufnr, lines, append)

Set buffer content with lines. Can append or replace existing content.

Parameters:

  • bufnr: Buffer number
  • lines: Array of lines to set
  • append: 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()

coc#list#select(bufnr, line)

Place selection sign on specified line in list buffer.

Parameters:

  • bufnr: Buffer number
  • line: 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()

coc#list#clean_up()

Close all list windows by buffer name pattern matching 'list://'.

Example:

" Close all list windows
call coc#list#clean_up()

Configuration

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
}

Highlight Groups

CocListLine

CocListLine

Current selected list line.

CocListSearch

CocListSearch

Matched characters in list.

CocListMode

CocListMode

Mode indicator text.

CocListPath

CocListPath

File path in list items.

CocSelectedText

CocSelectedText

Sign for selected text.

CocSelectedLine

CocSelectedLine

Selected line highlight.

Usage Examples

Basic List Usage

" 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>

Navigate List History

" 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>

Advanced List Options

" 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>

Custom List Mappings

" 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"
  }
}

List with Preview

function! PreviewList(source) abort
  execute 'CocList --normal --auto-preview ' . a:source
endfunction

nnoremap <silent> <leader>lp :call PreviewList('files')<CR>

Search in Files

" 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 Lists

" Interactive diagnostics
nnoremap <silent> <leader>di :CocList --interactive diagnostics<CR>

" Interactive symbols
nnoremap <silent> <leader>si :CocList --interactive symbols<CR>

List Status Display

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

" 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)

All Available Lists

function! ShowAvailableLists() abort
  execute 'CocList lists'
endfunction

command! Lists call ShowAvailableLists()

Location List Integration

" 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>

Custom List Source

" 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()

List with Filter

function! FilteredList(source, filter) abort
  execute 'CocList --input=' . a:filter . ' ' . a:source
endfunction

command! -nargs=+ FilterList call FilteredList(<f-args>)
" Usage: :FilterList files test

Diagnostic List by Severity

function! 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 List Access

" 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>

Error Handling

List Not Found

Handle cases where list source doesn't exist:

try
  CocList mylist
catch
  echohl Error
  echo "List source 'mylist' not found"
  echohl None
endtry

No Items in List

Check if list has items before navigation:

function! SafeListNext() abort
  try
    CocNext
  catch /no more/
    echo "Already at last item"
  endtry
endfunction

Preview Window Issues

Verify preview exists before operations:

if coc#list#has_preview()
  call coc#list#scroll_preview('down')
else
  echo "No preview window available"
endif

Troubleshooting

List Not Opening

  • Check if coc service is running: :CocInfo
  • Verify list source exists: :CocList lists
  • Check for errors: :messages

Search Not Working

  • Try --regex or --strict options for different matching
  • Check list.interactiveDebounceTime in settings
  • Verify input is being captured correctly

Preview Not Showing

  • Enable with --auto-preview flag
  • Check list.maxPreviewHeight setting
  • Verify enough screen space for preview

Mappings Not Working

  • Check list.insertMappings and list.normalMappings in settings
  • Verify no conflicting key mappings
  • Use :verbose map <key> to check mapping

Performance Issues with Large Lists

  • Use --interactive mode for better performance
  • Limit results with --number-select
  • Filter early with --input= option

See Also

  • Float Windows - Floating window management
  • Code Navigation - Navigation commands that use lists
  • Diagnostics - Diagnostic list source
  • Configuration - List settings configuration