Installing, updating, and managing coc.nvim extensions. Provides NPM-based extension ecosystem with automatic dependency management, VSCode extension compatibility, and comprehensive lifecycle management for language servers and additional functionality.
Install extensions from NPM registry or local sources with automatic dependency resolution and configuration management.
:CocInstall [{option}] {name} ...
" Install one or more extensions
" Parameters:
" {option} - string: installation options
" -terminal: show installation in terminal
" -sync: synchronous installation
" {name} - string: extension name(s)
CocAction('installExtension', {name})
" Install extension programmatically
" Parameters:
" {name} - string: extension name
" Returns: voidUsage Examples:
" Install popular extensions
:CocInstall coc-json coc-tsserver coc-python coc-css coc-html
" Install with terminal output
:CocInstall -terminal coc-eslint coc-prettier
" Install from specific source
:CocInstall coc-marketplace
" Batch install extensions
let g:coc_global_extensions = [
\ 'coc-json', 'coc-tsserver', 'coc-python', 'coc-css', 'coc-html',
\ 'coc-eslint', 'coc-prettier', 'coc-snippets', 'coc-pairs', 'coc-git'
\ ]
" Install extension programmatically
call CocAction('installExtension', 'coc-marketplace')Update, uninstall, and manage installed extensions with version control and dependency tracking.
:CocUninstall {name}
" Uninstall specified extension
" Parameters:
" {name} - string: extension name
:CocUpdate
" Update all installed extensions to latest versions
" Asynchronous operation with progress indication
:CocUpdateSync
" Update extensions synchronously
" Blocks until all updates complete
:CocRebuild
" Rebuild all extensions (runs npm rebuild)
" Useful after Node.js version changes
:CocWatch {extension}
" Watch extension for development
" Automatically reload on file changes
" Parameters:
" {extension} - string: extension name
CocAction('extensionStats')
" Get extension statistics and information
" Returns: array of extension stat objects
CocAction('loadedExtensions')
" Get list of currently loaded extensions
" Returns: array of extension names
CocAction('uninstallExtension', {name})
" Uninstall extension programmaticallyUsage Examples:
" Update all extensions
:CocUpdate
" Uninstall extension
:CocUninstall coc-eslint
" Check extension status
let stats = CocAction('extensionStats')
for stat in stats
echo stat.id . ': ' . stat.state
endfor
" Get loaded extensions
let loaded = CocAction('loadedExtensions')
echo 'Loaded extensions: ' . join(loaded, ', ')
" Rebuild after Node.js update
:CocRebuildDevelopment tools for creating, testing, and debugging coc.nvim extensions.
:CocWatch {extension}
" Watch extension for development
" Auto-reloads on file changes
" Parameters:
" {extension} - string: extension name
CocAction('reloadExtension', {name})
" Reload specific extension
" Parameters:
" {name} - string: extension name
" Returns: boolean - success status
CocAction('toggleExtension', {name})
" Enable/disable extension temporarily
" Parameters:
" {name} - string: extension nameUsage Examples:
" Watch extension during development
:CocWatch my-custom-extension
" Reload extension after changes
call CocAction('reloadExtension', 'coc-tsserver')
" Toggle extension temporarily
call CocAction('toggleExtension', 'coc-eslint')
" Development helper function
function! DevExtension(name)
call CocAction('reloadExtension', a:name)
echo a:name . ' reloaded'
endfunction
command! -nargs=1 DevExt call DevExtension(<q-args>)Commonly used extensions for different languages and development workflows.
" Language Server Extensions:
" coc-tsserver - TypeScript/JavaScript
" coc-python - Python (Pylsp/Pyright)
" coc-rust-analyzer - Rust
" coc-java - Java
" coc-go - Go
" coc-clangd - C/C++
" coc-css - CSS/SCSS/Less
" coc-html - HTML
" coc-json - JSON
" coc-yaml - YAML
" coc-xml - XML
" Development Tools:
" coc-eslint - ESLint integration
" coc-prettier - Code formatting
" coc-snippets - Snippet support
" coc-pairs - Auto pairs
" coc-git - Git integration
" coc-highlight - Document highlight
" coc-lists - Additional list sources
" coc-marketplace - Extension browser
" Framework Specific:
" coc-angular - Angular framework
" coc-react - React development
" coc-vue - Vue.js framework
" coc-svelte - Svelte frameworkUsage Examples:
" Full-stack JavaScript development setup
:CocInstall coc-tsserver coc-json coc-css coc-html coc-eslint coc-prettier
" Python development setup
:CocInstall coc-python coc-json coc-yaml
" Complete development environment
let g:coc_global_extensions = [
\ 'coc-json', 'coc-tsserver', 'coc-css', 'coc-html', 'coc-yaml',
\ 'coc-python', 'coc-eslint', 'coc-prettier', 'coc-snippets',
\ 'coc-pairs', 'coc-git', 'coc-highlight', 'coc-marketplace'
\ ]Configure extensions through coc-settings.json with extension-specific options and language server settings.
" Extension configuration in coc-settings.json:
" TypeScript/JavaScript (coc-tsserver)
"typescript.preferences.includePackageJsonAutoImports": "auto"
"typescript.suggest.autoImports": true
"javascript.suggest.autoImports": true
" Python (coc-python)
"python.pythonPath": "/usr/bin/python3"
"python.linting.enabled": true
"python.linting.pylintEnabled": true
" ESLint (coc-eslint)
"eslint.enable": true
"eslint.autoFixOnSave": true
"eslint.filetypes": ["javascript", "typescript", "react"]
" Prettier (coc-prettier)
"prettier.singleQuote": true
"prettier.tabWidth": 2
"prettier.semi": false
" Snippets (coc-snippets)
"snippets.userSnippetsDirectory": "~/.config/coc/ultisnips"
"snippets.extends": {"cpp": ["c"], "typescript": ["javascript"]}Usage Examples:
" Language-specific configuration
{
"languageserver": {
"golang": {
"command": "gopls",
"rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"],
"filetypes": ["go"],
"initializationOptions": {
"usePlaceholders": true
}
}
},
"coc.preferences.extensionUpdateCheck": "daily",
"coc.preferences.diagnostic.errorSign": "✗",
"coc.preferences.diagnostic.warningSign": "⚠"
}
" Auto-install extensions on startup
augroup coc_extensions
autocmd!
autocmd VimEnter * if empty(glob('~/.config/coc/extensions/node_modules/coc-tsserver'))
\ | CocInstall coc-tsserver | endif
augroup endManage extension lifecycle events, activation, and error handling for robust development environment.
" Extension events (autocmds):
" User CocNvimInit - After coc.nvim initialization
" User CocExtensionChange - Extension installed/uninstalled
" User CocServiceStart - Service started
" User CocServiceStop - Service stopped
CocAction('activeExtension', {name})
" Check if extension is active
" Returns: boolean
CocAction('extensionRoot', {name})
" Get extension installation directory
" Returns: string - path to extensionUsage Examples:
" Handle extension lifecycle
augroup coc_extension_events
autocmd!
autocmd User CocNvimInit call OnCocInit()
autocmd User CocExtensionChange call OnExtensionChange()
augroup end
function! OnCocInit()
echo "coc.nvim initialized"
" Setup custom configurations
endfunction
function! OnExtensionChange()
echo "Extensions changed, refreshing..."
call CocAction('refresh')
endfunction
" Check extension status
function! CheckExtension(name)
if CocAction('activeExtension', a:name)
echo a:name . ' is active'
else
echo a:name . ' is not active or not installed'
endif
endfunction
command! -nargs=1 CheckExt call CheckExtension(<q-args>)