Functions & Actions
Complete reference for all built-in Vimscript functions (coc#*), popup menu helpers (coc#pum#*), and the complete 60+ CocAction() catalog.
Vim Functions & CocAction Catalog
coc.nvim provides a comprehensive suite of Vimscript functions under the coc# namespace as well as the universal CocAction() and CocRequest() RPC dispatchers.
Core & Lifecycle Functions
coc#start([{option}])
Start the coc.nvim server process. Optional {option} dict can pass workspaceFolders or configuration overrides.
coc#refresh()
Trigger completion popup menu at the current cursor position. Typically mapped in insert mode:
| 1 | inoremap <silent><expr> <C-space> coc#refresh() |
coc#status([{escape}])
Returns a formatted status string suitable for statusline, winbar, or airline integration. Contains language server progress, diagnostic summaries, and background task statuses.
| 1 | set statusline+=%{coc#status()} |
coc#config({section}, {value})
Dynamically update a configuration setting in memory at runtime.
| 1 | call coc#config('suggest.autoTrigger', 'none') |
coc#add_command({id}, {command}, [{title}])
Register a custom user command from Vimscript to coc.nvim's internal command registry.
coc#on_enter()
Notify coc.nvim that <CR> was pressed in insert mode. Handles formatting and indentation rules for closing pairs and comments.
coc#expandable() & coc#jumpable() & coc#expandableOrJumpable()
Returns 1 if current position is on an expandable snippet or jumpable placeholder.
CocHasProvider({feature}, [{bufnr}])
Check if any active language server supports the specified LSP {feature} (e.g. 'hover', 'definition', 'rename', 'formatting', 'documentSymbol', 'codeAction').
| 1 | if CocHasProvider('hover') |
| 2 | call CocActionAsync('doHover') |
| 3 | endif |
CocTagFunc({pattern}, {flags}, {info})
Standard &tagfunc implementation for Vim 8.2+ / Neovim 0.5+. Enables standard Vim tag jumping (<C-]>) backed by LSP definitions.
| 1 | set tagfunc=CocTagFunc |
RPC Request & Action Functions
CocAction({action}, [...{args}])
Synchronously invoke an LSP action and return result. See the Complete CocAction() Catalog below.
CocActionAsync({action}, [...{args}])
Asynchronously invoke an LSP action in the background without blocking Vim UI. Recommended for interactive keymaps.
CocRequest({id}, {method}, [{params}])
Send a custom synchronous JSON-RPC request to language server {id} with LSP method name {method} and parameters {params}.
CocRequestAsync({id}, {method}, [{params}], [{callback}])
Send an asynchronous JSON-RPC request to language server {id} and receive response in {callback}.
CocNotify({id}, {method}, [{params}])
Send an LSP notification to language server {id}.
CocRegisterNotification({id}, {method}, {callback})
Register a callback handler for notifications received from language server {id}.
CocLocations({id}, {method}, [{params}], [{openCommand}])
Query locations from language server and populate quickfix / location list.
Popup Menu Functions (coc#pum#*)
The coc#pum# module provides complete control over coc.nvim's high-performance popup completion menu:
coc#pum#visible()
Returns 1 if the custom completion popup menu is currently visible, 0 otherwise.
coc#pum#next({insert})
Select next item in popup menu. If {insert} is 1, inserts text into buffer immediately.
coc#pum#prev({insert})
Select previous item in popup menu.
coc#pum#confirm()
Confirm selected completion item and expand snippets / apply additional text edits.
coc#pum#cancel()
Close popup menu and restore original pre-completion text.
coc#pum#insert()
Insert current selected item text into buffer without confirming.
coc#pum#select({index}, {insert}, {confirm})
Select item by 0-based index.
coc#pum#info()
Returns dictionary describing current popup menu state (selected index, total items, scroll position).
coc#pum#scroll({forward})
Scroll the documentation preview window attached to the popup menu.
Floating Window Functions (coc#float#*)
coc#float#has_float([{all}])
Returns 1 if any floating window or hover popup is currently open.
coc#float#close_all([{all}])
Close all open floating windows, hover popups, and signature help dialogs.
coc#float#close({winid})
Close specific floating window by window ID {winid}.
coc#float#has_scroll()
Returns 1 if the active float window contains scrollable content.
coc#float#scroll({forward}, [{amount}])
Scroll the contents of the active floating window forward (1) or backward (0).
| 1 | nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "<C-f>" |
| 2 | nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "<C-b>" |
Inline Completion & NextEdit
coc#inline#trigger([{option}])
Trigger inline ghost text completion suggestion (e.g. Copilot or LLM completions).
coc#inline#visible()
Returns 1 if inline suggestion is visible.
coc#inline#accept([{kind}])
Accept the current inline ghost text suggestion into buffer.
coc#inline#cancel()
Dismiss the current inline ghost text suggestion.
coc#nextedit#trigger() & coc#nextedit#accept()
Multi-line next-edit predictions engine navigation.
Notification & Utility Functions
coc#notify#close_all()
Close all active notification popups.
coc#notify#do_action([{winid}])
Execute primary action button on active notification popup.
coc#notify#copy()
Copy message content of active notification to system clipboard.
coc#util#get_config_home() & coc#util#get_data_home()
Get paths to config home and data home directories.
coc#util#extension_root()
Get root folder path where extensions are installed.
Complete CocAction() Catalog
Pass any of the following action strings to CocAction('actionName') or CocActionAsync('actionName'):
Code Navigation & Symbols
'jumpDefinition': Jump to definition of symbol under cursor.'jumpDeclaration': Jump to declaration of symbol.'jumpImplementation': Jump to implementation of interface/class.'jumpTypeDefinition': Jump to type definition.'jumpReferences': Find references of symbol.'jumpUsed': Find references excluding definition.'definitions': Return raw list of definition locations.'declarations': Return raw list of declaration locations.'implementations': Return raw list of implementation locations.'typeDefinitions': Return raw list of type definition locations.'references': Return raw list of reference locations.'documentSymbols': Return hierarchical document symbols tree.'getWorkspaceSymbols': Search workspace symbols by query string.'getCurrentFunctionSymbol': Get symbol information of current enclosing function.
Documentation & Signatures
'doHover': Show hover documentation popup for symbol under cursor.'getHover': Get raw hover documentation markdown string.'definitionHover': Show definition preview in float popup.'showSignatureHelp': Display signature help popup for current function call parameters.
Editing & Refactoring
'rename': Trigger workspace-wide symbol rename.'refactor': Open refactor buffer for interactive batch editing.'format': Format entire current document.'formatSelected': Format visual range or operator target.'codeAction': Open code actions menu for current line or selection.'codeActions': Return list of available code actions.'doCodeAction': Execute specific code action item.'doQuickfix': Apply first preferred quickfix for current diagnostic.'organizeImport': Automatically organize and remove unused imports.'fixAll': Automatically apply all auto-fixable diagnostics.'codeLensAction': Trigger CodeLens action on current line.'fold': Compute and apply LSP folding ranges.'highlight': Highlight all matching document symbols in current buffer.'rangeSelect': Trigger AST selection range expansion.
Diagnostics
'diagnosticList': Return list of all diagnostics across workspace.'diagnosticInfo': Open floating popup with full diagnostic info at cursor.'diagnosticToggle': Toggle diagnostics display on/off globally.'diagnosticToggleBuffer': Toggle diagnostics display for current buffer.'diagnosticPreview': Preview diagnostic message.'diagnosticRefresh': Force refresh diagnostics across active buffers.
Call Hierarchy & Type Hierarchy
'incomingCalls'&'showIncomingCalls': Show call hierarchy incoming callers.'outgoingCalls'&'showOutgoingCalls': Show call hierarchy outgoing callees.'showSuperTypes': Show supertypes of current symbol.'showSubTypes': Show subtypes of current symbol.
Outline & Tree Views
'showOutline': Open outline tree sidebar.'hideOutline': Close outline tree sidebar.
Workspace & Extensions Management
'addWorkspaceFolder': Add new workspace root folder.'removeWorkspaceFolder': Remove existing workspace root folder.'extensionStats': Return status array of all installed extensions.'toggleExtension': Enable or disable an extension.'uninstallExtension': Uninstall an extension.'reloadExtension': Reload an extension in place without restarting Vim.'services': Return list of registered language servers and status.'toggleService': Start or stop a language server service.
Complete function index
coc#add_command()— Add a custom Vim command to the commands list opened by :CocList commands. Example:call coc#add_command('mundoToggle', 'MundoToggle', \ 'toggle mundo window').
coc#compat#call()— Call the API function {name} with the {args} list (starting with nvim_) on Vim or Neovim; use: on vim9 to get the APIs supported on Vim. Example::echo coc#api#Get_api_info()[1]['functions'].
coc#config()— Change the user configuration, overwriting configurations from the user config file and default values. Example:call coc#config('coc.preferences', { \ 'willSaveHandlerTimeout': 1000, \}) call coc#config('languageserver', { \ 'ccls': { \ "command": "ccls", \ "trace.server": "verbose", \ "filetypes": ["c", "cpp", "objc", "objcpp"] \ } \}).
coc#expandable()— Check if a snippet is expandable at the current position. Requires coc-snippets extension installed.
coc#expandableOrJumpable()— Check if a snippet is expandable or jumpable at the current position. Requires coc-snippets extension installed.
coc#float#close_all()— Close all float windows/popups created by coc.nvim; set {all} to 1 to close all float windows/popups.
coc#float#close()— Close the float window/popup with {winid}.
coc#float#has_float()— Check whether a float window/popup exists; only coc.nvim's float windows/popups are checked by default.
coc#float#has_scroll()— Return 1 when there's a scrollable float window/popup created by coc.nvim.
coc#float#scroll()— Scroll all scrollable float windows/popups; scrolls backward when {forward} isn't 1. {amount} can be a number, or a full page when omitted. The popup menu is excluded.
coc#inline#accept()— Accept the current inline completion by inserting text into the current buffer when possible; nothing happens when inline completion isn't activated.
coc#inline#cancel()— Cancel the inline completion request and clear the inline completion virtual text of the current buffer. Return "".
coc#inline#next()— Navigate to the next inline completion item. Return "".
coc#inline#prev()— Navigate to the previous inline completion item. Return "".
coc#inline#trigger()— coc#inline#trigger() Vim function.
coc#inline#visible()— Return 1 when inline completion visual text exists for the current buffer.
coc#jumpable()— Check if a snippet is jumpable at the current position.
coc#nextedit#accept()— Accept the current Next Edit action asynchronously. An off-cursor or cross-file candidate is first opened and previewed; a second call applies the edit. Returns "" and does nothing when no candidate is available.
coc#nextedit#available()— Return 1 when a Next Edit candidate is ready to jump or apply in the current buffer, otherwise return 0.
coc#nextedit#cancel()— Cancel the current request or preview and clear all Next Edit UI state. Returns "".
coc#nextedit#clear()— Clear Next Edit virtual text and buffer-local state. When {bufnr} is omitted, clear the current buffer.
coc#nextedit#next()— Select the next candidate, wrapping to the first candidate. Returns "".
coc#nextedit#prev()— Select the previous candidate, wrapping to the last candidate. Returns "".
coc#nextedit#trigger()— Trigger a Next Edit request for the current buffer asynchronously and return "", so this function can be used in an <expr> mapping.
coc#nextedit#visible()— Return 1 when a Next Edit preview is visible in the current buffer, otherwise return 0. A ready navigation indicator is not a preview.
coc#notify#close_all()— Close all notification windows.
coc#notify#copy()— Copy all content from the notifications to the system clipboard.
coc#notify#do_action()— Invoke the action for all notification windows, or for a particular window with winid.
coc#notify#keep()— Stop the auto-hide timer of notification windows.
coc#notify#show_sources()— Show the source name (extension name) in notification windows.
coc#on_enter()— Notify coc.nvim that <CR> has been pressed.
coc#pum#cancel()— Close the customized popupmenu and reset the trigger input before the cursor when the trigger was changed by pum navigation, like Vim's <C-e>.
coc#pum#confirm()— Confirm completion of the selected item (when possible) by inserting the word of the completion item when it isn't already inserted, and close the customized popup menu, like Vim's <C-y>. Triggers the optional onCompleteDone handler of the completion source after the buffer text changes.
coc#pum#has_item_selected()— Check whether a completion item is selected in the popup menu. Returns 1 when a completion item is selected.
coc#pum#info()— Return information about the customized popupmenu; should only be used when coc#pum#visible() is 1.
coc#pum#insert()— Insert the word of the currently selected item and finish the completion. Unlike coc#pum#confirm(), no text edit is applied and the snippet isn't expanded.
coc#pum#next()— Select the next item of the customized popupmenu; insert the word when {insert} is 1.
coc#pum#one_more()— Insert one more character from the current completion item (the first item when none is selected); works like <CTRL-L> of popupmenu-keys. Note that the word of the completion item should start with the current input.
coc#pum#prev()— Select the previous item of the customized popupmenu; insert the word when {insert} is truthy.
coc#pum#scroll()— Scroll the popupmenu forward or backward by page. A timer is used to make it work as the {rhs} of key-mappings. Returns <Ignore>.
coc#pum#select_confirm()— Select the first completion item if none is selected, then confirm the completion like coc#pum#confirm().
coc#pum#select()— Select a completion item in the completion popupmenu, with optional {insert} and {confirm} actions. Returns an empty string.
coc#pum#stop()— Close the customized popupmenu and stop the completion; works like Vim's <C-x><C-z>.
coc#pum#visible()— Check whether the customized popupmenu is visible, like pumvisible() does. Returns 1 when the popup menu is visible.
coc#refresh()— Start or refresh completion at the current cursor position. Bind this to 'imap' to trigger completion. Example:if has('nvim') inoremap <silent><expr> <c-space> coc#refresh() else inoremap <silent><expr> <c-@> coc#refresh() endif.
coc#snippet#next()— Jump to the next placeholder; does nothing when coc#jumpable() is 0.
coc#snippet#prev()— Jump to the previous placeholder; does nothing when coc#jumpable() is 0.
coc#start()— Start completion with the optional {option}. The option can contain.
coc#status()— Return a status string that can be used in the status line. The status includes diagnostic information from b:coc_diagnostic_info and extension-contributed statuses from g:coc_status. For statusline integration, see coc-status.
coc#util#api_version()— Get coc.nvim's Vim API version number, starting from 1.
coc#util#extension_root()— Return the extensions root of coc.nvim.
coc#util#get_config_home()— Get the config directory that contains the user's coc-settings.json.
coc#util#get_config()— Get the configuration of the current document (mostly defined in coc-settings.json) by {key}. Example::echo coc#util#get_config('coc.preferences').
coc#util#get_data_home()— Get the data home directory. Returns g:coc_data_home when defined; otherwise uses $XDG_CONFIG_HOME/coc when $XDG_CONFIG_HOME exists, falling back to /AppData/Local/coc on Windows and /.config/coc on other systems.
coc#util#job_command()— Get the job command used for starting the coc service.
coc#util#root_patterns()— Get the root patterns used for the current document.
CocAction()— Run {action} of coc with optional extra {args}.
CocActionAsync()— Call CocAction by sending a notification to the NodeJS process of coc.nvim.
CocHasProvider()— Check whether a provider exists for the specified feature of the current buffer or the {bufnr} buffer. Supported features.
CocLocations()— Send a location request to the language client of {id} with {method} and optional {params}. {openCommand}: Optional command used to open the buffer, defaulting to coc.preferences.jumpCommand (:edit by default). When it's v:false, the locations list is always used. Example:call CocLocations('ccls', '$ccls/call', {'callee': v:true}) call CocLocations('ccls', '$ccls/call', {}, 'vsplit').
CocLocationsAsync()— Same as CocLocations(), but sends a notification to the server instead of a request.
CocNotify()— Send a notification to a remote language server. Example:call CocNotify('ccls', '$ccls/reload').
CocRegisterNotification()— Register a notification callback for the specified client {id} and {method} {callback} is called with a single parameter, the notification result. Example:autocmd User CocNvimInit call CocRegisterNotification('ccls', \ '$ccls/publishSemanticHighlight', function('s:Handler')).
CocRequest()— Send a request to the language client of {id} with {method} and optional {params}. A Vim error is raised if the response contains an error. Example:call CocRequest('tslint', 'textDocument/tslint/allFixes', \ {'textDocument': {'uri': 'file:///tmp'}}).
CocRequestAsync()— Send an async request to a remote language server. {callback}: A function called with the error and response.
CocTagFunc()— Used for Vim's 'tagfunc' option to make tag search by CTRL-] use coc.nvim as the provider; a fallback tag search is performed when coc.nvim returns no result.
Complete CocAction index
CocAction('activeExtension')— Activate the extension with {id}.
CocAction('addRanges')— Ranges must be provided as an array of range type: https://git.io/fjiEG.
CocAction('addWorkspaceFolder')— Add {folder} to the workspace folders; {folder} should be an existing directory on the file system.
CocAction('codeAction')— Prompt for a code action and do it.
CocAction('codeActionRange')— Run a code action for the range.
CocAction('codeActions')— Get the codeActions list of the current document.
CocAction('codeLensAction')— Invoke the command for the codeLens of the current line (or the line containing a codeLens just above). A prompt is shown when multiple actions are available.
CocAction('colorPresentation')— Change the color presentation at the current color position, requires documentColor provider CocHasProvider().
CocAction('commands')— Get a list of available service commands for the current buffer.
CocAction('deactivateExtension')— Deactivate the extension with {id}.
CocAction('declarations')— Get the declaration location(s) of the symbol under the cursor. Returns LSP Location Location[] LocationLink[].
CocAction('definitionHover')— Same as CocAction('doHover'), but includes definition contents from the definition provider when possible.
CocAction('definitions')— Get the definition locations of the symbol under the cursor. Returns LSP Location[].
CocAction('diagnosticInfo')— Show the diagnostic message at the current position without truncating it.
CocAction('diagnosticList')— Get all diagnostic items of the current Neovim session.
CocAction('diagnosticPreview')— Show diagnostics under current cursor in preview window.
CocAction('diagnosticRefresh')— Force refresh diagnostics for the buffer with {bufnr}, or all buffers when {bufnr} doesn't exist. Returns v:null before diagnostics are shown.
CocAction('diagnosticToggle')— Enable/disable diagnostics on the fly. This setting is ignored when displayByAle is enabled. You can toggle by specifying {enable}; {enable} can be 0 or 1.
CocAction('diagnosticToggleBuffer')— Toggle diagnostics for a specific buffer; the current buffer is used when {bufnr} isn't provided. You can toggle by specifying {enable}; {enable} can be 0 or 1.
CocAction('doCodeAction')— Do a codeAction.
CocAction('documentSymbols')— Get a list of symbols of current buffer or specific {bufnr}.
CocAction('doHover')— Show documentation of the current symbol; returns v:false when no hover is found.
CocAction('doQuickfix')— Do the first preferred quickfix action on the current line.
CocAction('ensureDocument')— Ensure the current or specified document is attached to coc.nvim coc-document-attached; use this when you need to invoke an action of the current document on buffer create.
CocAction('extensionStats')— Get all extension states as a list, including id, root, and state.
CocAction('fixAll')— Run the fixAll codeAction for the current buffer. Shows a warning when no codeAction is found.
CocAction('fold')— Fold the current buffer; optionally use {kind} for a specific FoldingRangeKind. {kind} can be 'comment', 'imports', or 'region'.
CocAction('format')— Format the current buffer using the language server. Returns v:false when formatting fails.
CocAction('formatSelected')— Format the selected range; {mode} should be one of v, V, char, line.
CocAction('getCurrentFunctionSymbol')— Return the function string that the current cursor is in.
CocAction('getHover')— Get a documentation text array at {hoverLocation} or the current position; returns an array of strings.
CocAction('getWordEdit')— Get the workspaceEdit of the current word, using the language server when possible and extracting the word from the current buffer as a fallback.
CocAction('getWorkspaceSymbols')— Get workspace symbols from {input}.
CocAction('hideOutline')— Close coc-outline in the current tab. Throws a Vim error when it can't be closed by Vim.
CocAction('highlight')— Highlight the symbols under the cursor.
CocAction('implementations')— Get the implementation locations of the symbol under the cursor. Returns LSP Location[].
CocAction('incomingCalls')— Retrieve incoming calls from {CallHierarchyItem}, or from the current position when it isn't provided.
CocAction('inspectSemanticToken')— Inspect semantic token information at the cursor position.
CocAction('jumpDeclaration')— Jump to the declaration locations of the current symbol. Returns v:false when no location is found.
CocAction('jumpDefinition')— Jump to the definition locations of the current symbol. Returns v:false when no location is found.
CocAction('jumpImplementation')— Jump to the implementation locations of the current symbol. Returns v:false when no location is found.
CocAction('jumpReferences')— Jump to the reference locations of the current symbol; use CocAction('jumpUsed') to exclude declaration locations.
CocAction('jumpTypeDefinition')— Jump to the type definition locations of the current symbol. Returns v:false when no location is found.
CocAction('jumpUsed')— Jump to reference locations without declarations.
CocAction('links')— Return the document link list of the current buffer.
CocAction('openLink')— Open a link under the cursor with {command}. {command} defaults to edit.
CocAction('organizeImport')— Run the organize import code action for the current buffer. Returns false when the code action doesn't exist.
CocAction('outgoingCalls')— Retrieve outgoing calls from {CallHierarchyItem}, or from the current position when it isn't provided.
CocAction('pickColor')— Change the color at the current cursor position; requires a documentColor provider CocHasProvider().
CocAction('quickfixes')— Get the quickfix codeActions of the current buffer.
CocAction('rangeSelect')— Visually select the previous or next selection range; requires a selectionRange provider.
CocAction('refactor')— Open coc-refactor-buffer with the current symbol as activated cursor ranges. Requires LSP rename support enabled for the current buffer; use :CocSearch when rename support isn't available.
CocAction('references')— Get the reference locations of the symbol under the cursor.
CocAction('reloadExtension')— Reload an activated extension.
CocAction('removeWorkspaceFolder')— Remove workspace folder {folder}; {folder} should be an existing directory on the file system.
CocAction('rename')— Rename the symbol under the cursor; coc-dialog-input is shown to prompt for a new name.
CocAction('resolveWorkspaceSymbol')— Resolve the location for workspace {symbol}.
CocAction('runCommand')— Run a global command provided by the language server. If {name} isn't provided, a prompt with a list of commands is shown for selection.
CocAction('selectionRanges')— Get the selection ranges of the current position from the language server.
CocAction('semanticHighlight')— Request semantic tokens highlighting for the current buffer.
CocAction('sendNotification')— Send an LSP notification to the language server with {id}.
CocAction('sendRequest')— Send an LSP request with {method} and {params} to the language server of {id} (check the id with :CocList services). Check out the LSP specification at https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/
CocAction('services')— Get an information list for all services.
CocAction('showIncomingCalls')— Show the incoming calls of the current function with coc-tree; see coc-callHierarchy.
CocAction('showOutgoingCalls')— Show the outgoing calls of the current function with coc-tree.
CocAction('showOutline')— Show coc-outline for the current buffer. Does nothing when the outline window is already shown for the current buffer.
CocAction('showSignatureHelp')— Echo signature help of the current function; returns v:false when no signature is found.
CocAction('showSubTypes')— Show the sub types of the type under the cursor with coc-tree; see coc-typeHierarchy. A warning is shown when no type is found under the cursor.
CocAction('showSuperTypes')— Show the super types of the type under the cursor with coc-tree; see coc-typeHierarchy. A warning is shown when no type is found under the cursor.
CocAction('snippetCancel')— Cancel current snippet session.
CocAction('snippetInsert')— Insert {snippet} text as the {range} of the current buffer.
CocAction('sourceStat')— Get the list of completion source stats for the current buffer.
CocAction('toggleExtension')— Enable/disable an extension.
CocAction('toggleService')— Start or stop a service.
CocAction('toggleSource')— Enable/disable {source}.
CocAction('typeDefinitions')— Get the type definition locations of the symbol under the cursor. Returns LSP Location[].
CocAction('uninstallExtension')— Uninstall an extension.