tessl install tessl/npm-coc-nvim@0.0.0LSP based intellisense engine for neovim & vim8.
Coc.nvim is a comprehensive Language Server Protocol (LSP) based intellisense engine that brings VSCode-like development experience to Neovim and Vim8. It provides a rich extension ecosystem with support for code completion, diagnostics, code actions, document highlights, formatting, snippets, and workspace management.
Plug 'neoclide/coc.nvim', {'branch': 'release'} (vim-plug)" Install coc.nvim with vim-plug
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Install extensions
let g:coc_global_extensions = ['coc-json', 'coc-tsserver', 'coc-python']
" Configure key mappings
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Completion with Tab
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunctionThis section helps you quickly find the right API for common tasks:
<Plug>(coc-definition) or CocAction('jumpDefinition')<Plug>(coc-references) or CocAction('references')<Plug>(coc-type-definition)CocAction('showIncomingCalls') / CocAction('showOutgoingCalls'):CocList symbols or CocAction('workspaceSymbols')coc#refresh() or coc#start()CocAction('doHover') or CocHasProvider('hover'):CocDiagnostics or CocAction('diagnosticList')<Plug>(coc-codeaction) or CocAction('codeAction')<Plug>(coc-rename) or CocAction('rename')<Plug>(coc-format) or CocAction('format'):CocInstall <extension>:CocList extensions:CocUpdateCocAction('extensionStats'):CocConfigcoc#config('key', value)coc#util#get_config('key')coc#float#create_float_win()coc#float#scroll(1) (down) or coc#float#scroll(0) (up)coc#float#close_all():CocList locationThese APIs cover 80% of common use cases and are safe to use for beginners:
Code Navigation
<Plug>(coc-definition) " Jump to definition
<Plug>(coc-references) " Find references
<Plug>(coc-implementation) " Go to implementationCode Completion
coc#refresh() " Trigger completion
coc#pum#visible() " Check if popup visible
coc#pum#confirm() " Accept completion
coc#_select_confirm() " Select first and confirmDiagnostics
:CocDiagnostics " Show all diagnostics
<Plug>(coc-diagnostic-next) " Next diagnostic
<Plug>(coc-diagnostic-prev) " Previous diagnostic
CocAction('diagnosticInfo') " Show diagnostic at cursorCode Actions
<Plug>(coc-codeaction) " Show code actions
<Plug>(coc-fix-current) " Apply quickfix
<Plug>(coc-rename) " Rename symbol
CocAction('format') " Format bufferConfiguration
:CocConfig " Edit settings
:CocInstall <extension> " Install extension
let g:coc_global_extensions = [] " Auto-install listThese APIs provide more control and are useful once you're comfortable with the basics:
Advanced Navigation
CocAction('jumpDefinition', 'split') " Jump in split
CocAction('definitions') " Get definition locations
CocAction('typeDefinitions') " Get type locations
CocAction('showIncomingCalls') " View call hierarchySmart Completion
coc#start({'source': 'file'}) " Trigger specific source
coc#expandableOrJumpable() " Check snippet state
coc#pum#select(index, insert, confirm) " Select specific item
CocAction('sourceStat') " Get source statisticsDiagnostic Management
CocAction('diagnosticList') " Get all diagnostics
CocAction('diagnosticToggle') " Toggle diagnostics
CocAction('diagnosticNext', 'error') " Jump to next error only
CocAction('diagnosticRefresh') " Force refreshCode Intelligence
CocAction('codeActions', 'cursor') " Get available actions
CocAction('quickfixes', 'line') " Get quickfixes
CocAction('organizeImport') " Organize imports
CocAction('formatSelected', mode) " Format selectionFloat Windows
coc#float#has_scroll() " Check if scrollable
coc#float#scroll(forward, amount) " Scroll with control
coc#float#jump() " Jump to float
coc#float#get_float_win_list() " Get float windowsThese APIs are for advanced users building custom integrations or workflows:
RPC Communication
CocRequest(id, method, params) " Sync LSP request
CocRequestAsync(id, method, params, cb) " Async LSP request
CocNotify(id, method, params) " LSP notification
CocLocations(id, method, ...) " Query locationsCustom Float Windows
coc#float#create_float_win(winid, bufnr, config) " Create custom float
coc#float#create_buf(bufnr, lines, mode) " Create float buffer
coc#float#change_height(winid, delta) " Resize floatAdvanced Utilities
coc#rpc#request(method, args) " RPC to coc service
coc#api#call(method, args) " API with error handling
coc#client#create(name, command) " Create LSP client
coc#util#jump(cmd, filepath, line, col) " Custom jumpWindow and Cursor Management
coc#cursor#position() " Get LSP position
coc#cursor#move_to(line, character) " Move to position
coc#window#visible_range(bufnr) " Get visible range
coc#window#set_var(winid, name, value) " Set window variableExtension Development
coc#add_command(id, cmd, title) " Register command
coc#add_extension(...names) " Add to auto-install
CocAction('activeExtension', name) " Activate extension
CocAction('reloadExtension', name) " Reload extensionMany coc.nvim APIs use LSP (Language Server Protocol) data structures:
" LSP Position object (0-indexed)
{
'line': 5, " Line number (0-indexed)
'character': 10 " Character offset (0-indexed, UTF-16 code units)
}" LSP Range object
{
'start': {'line': 5, 'character': 0},
'end': {'line': 5, 'character': 10}
}" LSP Location object
{
'uri': 'file:///path/to/file.js',
'range': {
'start': {'line': 5, 'character': 0},
'end': {'line': 5, 'character': 10}
}
}" Diagnostic object
{
'range': {'start': {...}, 'end': {...}},
'severity': 1, " 1=Error, 2=Warning, 3=Information, 4=Hint
'message': 'Error message',
'source': 'typescript',
'code': 'TS2304'
}Note: Vim uses 1-indexed line/column positions, while LSP uses 0-indexed positions. Coc.nvim handles conversions automatically in most APIs.
Coc.nvim uses a client-server architecture:
~/.config/coc/extensionscoc-settings.json with schema validationKey components:
CocActionAsync, CocRequestAsync) for non-blocking operationsFor complete documentation, navigate to topic-specific files using the links above.