Skip to main content
Docs / VIM INTERFACE

Variables (g:, b:, w:, $)

Complete reference for all global, buffer, window, and environment variables in coc.nvim.

Vim Variables Reference

coc.nvim provides global (g:), buffer-local (b:), window-local (w:), and environment ($) variables for dynamic configuration, per-buffer overrides, and inspecting real-time LSP runtime state.

Environment Variables ($)

$COC_NODE_PATH

Set custom Node.js binary path used to start the coc.nvim background service. If not specified, coc.nvim searches your system $PATH. Can also be configured via g:coc_node_path.

$COC_VIM_CHANNEL_ENABLE

Enable Vim channel logging (|ch_logfile()|) when set to "1". Useful for low-level IPC communication debugging.

$NVIM_COC_LOG_LEVEL

Set the logging level for coc.nvim daemon. Supported values: "trace", "debug", "info", "warn", "error", "off". Default is "info".

$NVIM_COC_LOG_FILE

Set custom file path for writing coc.nvim log output. Default location is accessible via :CocOpenLog.

$COC_DATA_HOME

Set root folder for coc.nvim data directory (installed extensions, downloaded language servers, mru cache).


Buffer Variables (b:)

Buffer variables allow fine-grained, buffer-local overrides that take precedence over global settings.

b:coc_enabled

Type: number (0 or 1)
Default: 1
Enable or disable coc.nvim entirely for the current buffer. When set to 0, coc.nvim detaches LSP document synchronization and completion for this buffer.

b:coc_disable_autoformat

Type: number (0 or 1)
Disable automatic format on save for this buffer, even if coc.preferences.formatOnSave is enabled globally.

b:coc_force_attach

Type: number (0 or 1)
Force attach language servers to this buffer even if file size exceeds configured limits or filetype is ignored.

b:coc_root_patterns

Type: list of string
List of root pattern filenames / directory names (e.g. ['.git', 'package.json', 'Cargo.toml']) used to resolve workspace root for the current buffer.

b:coc_suggest_disable

Type: number (0 or 1)
Disable auto-triggering of completion popup for the current buffer. Manual completion via coc#refresh() is still available.

b:coc_inline_disable

Type: number (0 or 1)
Disable inline completion (ghost text suggestions) for the current buffer.

b:coc_disabled_sources

Type: list of string
List of completion source names (e.g. ['around', 'buffer', 'file']) to disable for current buffer.

b:coc_suggest_blacklist

Type: list of string
Blacklist of keyword tokens or patterns that should be filtered out from completion popup in this buffer.

b:coc_additional_keywords

Type: list of string
Additional characters to consider as keyword characters for completion trigger and filtering in this buffer.

b:coc_trim_trailing_whitespace

Type: number (0 or 1)
Whether to trim trailing whitespace automatically on save for this buffer.

b:coc_trim_final_newlines

Type: number (0 or 1)
Whether to trim redundant empty lines at the end of file on save for this buffer.

b:WorkspaceFolders

Type: list of string
List of workspace folder paths explicitly assigned to the current buffer.


Window Variables (w:)

w:cocViewId

Type: string
ID of the tree view rendered inside the current window (e.g. "coc-outline" or custom extension tree views).


Global Configuration Variables (g:)

Configure these variables in your .vimrc or init.vim prior to plugin startup:

g:coc_global_extensions

Type: list of string
List of extension names to automatically install on startup if missing.
Example: let g:coc_global_extensions = ['coc-json', 'coc-tsserver', 'coc-pyright', 'coc-snippets']

g:coc_start_at_startup

Type: number (0 or 1)
Default: 1
Whether to start coc.nvim server process automatically on Vim startup. Set to 0 to defer startup until :CocStart.

g:coc_node_path

Type: string
Absolute path to Node.js executable used by coc.nvim.

g:coc_node_args

Type: list of string
Custom arguments passed to Node.js runtime (e.g. ['--nolazy', '--max-old-space-size=4096']).

g:coc_config_home

Type: string
Custom directory path for resolving coc-settings.json. Default is ~/.config/coc on Linux/macOS.

g:coc_data_home

Type: string
Custom directory path for coc.nvim runtime data and extensions.

g:coc_user_config

Type: dict
In-memory dictionary providing initial user configuration settings, merged with coc-settings.json.

g:coc_filetype_map

Type: dict
Mapping of Vim &filetype names to LSP language IDs.
Example: let g:coc_filetype_map = {'typescriptreact': 'typescript.tsx'}

g:coc_snippet_next & g:coc_snippet_prev

Type: string
Key sequences used to jump forward and backward across active snippet placeholders.
Default: '<C-j>' and '<C-k>'.

g:coc_enable_locationlist

Type: number (0 or 1)
Default: 0
When set to 1, coc.nvim populates Vim location list instead of quickfix list for jump locations.

g:coc_quickfix_open_command

Type: string
Default: 'copen'
Vim command used to open quickfix window when multiple jump locations exist.

g:coc_open_url_command

Type: string
Custom command used to open URLs (e.g. 'xdg-open', 'open', or 'start').

g:coc_disable_startup_warning

Type: number (0 or 1)
Default: 0
Disable warning notifications about Node.js versions or outdated Vim builds.

g:coc_disable_mappings_check

Type: number (0 or 1)
Disable startup checks for conflicting key mappings (like recursive <Plug> mappings).

g:coc_disable_uncaught_error

Type: number (0 or 1)
Disable popups for uncaught background JavaScript exceptions.

g:coc_borderchars & g:coc_border_joinchars

Type: list of string
Border characters used for floating windows.
Default: ['─', '│', '─', '│', '┌', '┐', '┘', '└']

g:coc_notify

Type: number (0 or 1)
Default: 1
Enable built-in notification popups for messages and progress reporting.

g:coc_notify_error_icon, g:coc_notify_warning_icon, g:coc_notify_info_icon

Type: string
Icons used in notification popups. Defaults: '', '', ''.


Runtime State Variables (g: & b:)

Read-only variables populated by coc.nvim during active editing:

g:coc_service_initialized

Type: number (0 or 1)
Set to 1 once the background Node.js service is fully initialized and ready to receive requests.

g:coc_process_pid

Type: number
Process ID (PID) of the coc.nvim Node.js background process.

g:coc_status

Type: string
Current status message displayed in statusline by coc#status() (active language server status, progress indicators, snippet mode).

g:WorkspaceFolders

Type: list of string
List of all active workspace root paths registered across all language servers.

g:coc_jump_locations

Type: list of dict
Locations list generated by the last definition, reference, or symbol jump action.

b:coc_diagnostic_info

Type: dict
Diagnostic counts for the current buffer. Dictionary keys:

  • information: count of info diagnostics
  • hint: count of hints
  • warning: count of warnings
  • error: count of errors
vim snippet
1" Example statusline diagnostic helper
2function! StatusDiagnostic(bufnr) abort
3 let info = getbufvar(a:bufnr, 'coc_diagnostic_info', {})
4 if empty(info) | return '' | endif
5 let msgs = []
6 if get(info, 'error', 0) > 0 | call add(msgs, 'E:' . info['error']) | endif
7 if get(info, 'warning', 0) > 0 | call add(msgs, 'W:' . info['warning']) | endif
8 return join(msgs, ' ')
9endfunction

b:coc_current_function

Type: string
Name of the enclosing function, method, or class under the current cursor position (populated via document symbols).

b:coc_snippet_active

Type: number (0 or 1)
Set to 1 when cursor is inside an active expandable snippet session.

b:coc_cursors_activated

Type: number (0 or 1)
Set to 1 when a multiple cursors session is active in the current buffer.

<!-- generated-current-vim-reference -->

Variable scope and source metadata

The scope labels and defaults below come from the pinned coc.txt snapshot. A default is shown only when the source explicitly states one. The current source snapshot has no variable-level deprecation or replacement markers, so no replacement is inferred.

Complete variable index

  • $COC_NODE_PATH — Full path of the NodeJS executable used to start the node process; the node command is used when the variable doesn't exist. Scope: Environment ($). Default: not stated in current coc.txt.

  • $COC_VIM_CHANNEL_ENABLE — Enable Vim's channel log ch_logfile() when it's "1". Scope: Environment ($). Default: not stated in current coc.txt.

  • $NODE_CLIENT_LOG_FILE — Full path of the client log file, used when g:node_client_debug is enabled. Scope: Environment ($). Default: not stated in current coc.txt.

  • $VIMCONFIG — Full path of the directory used to contain the user configuration file; not used when g:coc_config_home exists. Scope: Environment ($). Default: not stated in current coc.txt.

  • b:coc_additional_keywords — Additional keyword characters used for generating keywords. Example: " Add keyword characters for CSS autocmd FileType css let b:coc_additional_keywords = ["-"]. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_current_function — Function string that the current cursor is in. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_cursors_activated — Use the expression get(b:, 'coc_cursors_activated',0) to check whether a cursors session is activated for the current buffer. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_diagnostic_disable — Disable diagnostic support for the current buffer. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_diagnostic_info — Diagnostic information of the current buffer; the format looks like. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_diagnostic_mapdiagnostic-structure Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_disable_autoformat — Set to 1 on buffer create if you don't want coc.nvim to format the buffer automatically (when typing or saving the buffer). Normally used with a BufRead autocmd. Example: " Disable automatic format with file size > 1MB. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_disabled_sources — Disabled completion sources of the current buffer. Example: let b:coc_disabled_sources = ['around', 'buffer', 'file']. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_enabled — Set to 0 on buffer create if you don't want coc.nvim to receive content from the buffer. Normally used with a BufRead autocmd. Example: " Disable file with size > 1MB. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_force_attach — When it's 1, attach the buffer without checking the 'buftype' option. Should be set on buffer create. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_inline_disable — Disable inline completion triggering for the buffer. Example: " Disable inline completion for python autocmd FileType python let b:coc_inline_disable = 1. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_root_patterns — Root patterns used for resolving the workspaceFolder of the current file; these take precedence over the "workspace.rootPatterns" setting. Example: autocmd FileType python let b:coc_root_patterns = \ ['.git', '.env']. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_snippet_active — Is 1 when a snippet session is activated; use coc#jumpable() to check whether it's possible to jump to a placeholder. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_suggest_blacklist — List of input words for which completion should not be triggered. Example: " Disable completion for 'end' in Lua files autocmd FileType lua let b:coc_suggest_blacklist = ["end"]. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_suggest_disable — Disable completion triggering for the buffer. Example: " Disable completion for python autocmd FileType python let b:coc_suggest_disable = 1. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_trim_final_newlines — Trim all newlines after the final newline at the end of the file. Used by the "FormattingOptions" sent to the server. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • b:coc_trim_trailing_whitespace — Trim trailing whitespace on a line, default 0. Used by the "FormattingOptions" sent to the server. Scope: Buffer-local (b:). Default: not stated in current coc.txt.

  • g:coc_border_joinchars — Border join characters used by float windows/popups, defaulting to: Note: you may need a special font like Nerd Font to display them. Example: ['┬', '┤', '┴', '├']. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_borderchars — Border characters used by the border window, defaulting to: Note: you may need a special font like Nerd Font to display them. Example: ['─', '│', '─', '│', '┌', '┐', '┘', '└']. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_config_home — Configure the directory used to look for the user's coc-settings.json. Default. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_data_home — Configure the directory used for data files (extensions, MRU, and so on). Default. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_default_semantic_highlight_groups — Create default semantic highlight groups for coc-semantic-highlights. Scope: Global (g:). Default: 1.

  • g:coc_disable_mappings_check — Disable completion key-mappings check for <tab>, <cr>, <c-y>, <s-tab>. Scope: Global (g:). Default: 0.

  • g:coc_disable_startup_warning — Disable the possible warning on startup for old Vim/Node versions. Scope: Global (g:). Default: 0.

  • g:coc_disable_transparent_cursor — Disable the transparent cursor when CocList is activated. Set it to 1 if you have issues with the transparent cursor. Scope: Global (g:). Default: 0.

  • g:coc_disable_uncaught_error — Disable uncaught error messages from node process of coc.nvim. Scope: Global (g:). Default: 0.

  • g:coc_enable_locationlist — Use location list of coc-list when jump to locations. Scope: Global (g:). Default: 1.

  • g:coc_filetype_map — Map for document filetypes so the server can handle the current document as another filetype Default: {}. Example: let g:coc_filetype_map = { \ 'html.swig': 'html', \ 'wxss': 'css', \ }. Scope: Global (g:). Default: {}.

  • g:coc_global_extensions — Global extension names to install when they aren't installed. Note: coc.nvim will try to install the extensions in this list that aren't installed after initialization. Example: let g:coc_global_extensions = ['coc-json', 'coc-git']. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_highlight_maximum_count — When the number of highlight items exceeds the maximum count, they're grouped and added using timer_start for a better user experience. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_jump_locations — This variable is set to jump locations when the CocLocationsChange autocmd fires. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_last_float_win — Window id of latest created float/popup window. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_last_hover_message — Last message echoed from doHover; can be used in the statusline. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_list_preview_filetype — Enable setting the filetype for the buffer in the preview window of CocList. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_markdown_disabled_languages — List of filetypes for which highlighting in markdown blocks should be disabled; useful for filetypes that can be slow with syntax highlighting. Example: let g:coc_markdown_disabled_languages = ['html']. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_max_treeview_width — Maximum width of the tree view when adjusted by auto width. Scope: Global (g:). Default: 40.

  • g:coc_node_args — Arguments passed to node when starting coc.nvim service. Useful for starting coc.nvim in debug mode Default: []. Example: let g:coc_node_args = ['--nolazy', '--inspect-brk=6045']. Scope: Global (g:). Default: [].

  • g:coc_node_path — Path to the node executable used to start the coc service Use this when coc has problems with your system node. Example: let g:coc_node_path = '/usr/local/opt/node@12/bin/node'. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_notify — g:coc_notify Vim interface variable. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_notify_error_icon — Error icon for notification, default to:  Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_notify_info_icon — Info icon for notification, default to:  Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_notify_warning_icon — Warning icon for notification, default to: ⚠ Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_open_url_command — Command used to open remote URLs; when not set, coc.nvim tries "open" and "xdg-open" on macOS and Linux, and "cmd /c start" on Windows. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_process_pid — PID of the coc.nvim service process. If your Vim doesn't kill the coc.nvim process on exit, use: in your vimrc. Example: autocmd VimLeavePre * if get(g:, 'coc_process_pid', 0) \ | call system('kill -9 '.g:coc_process_pid) | endif. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_prompt_win_width — Width of input prompt window, default 32. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_quickfix_open_command — Command used to open the quickfix list. To jump to the first position after the quickfix list opens, you can use: Default: copen. Example: let g:coc_quickfix_open_command = 'copen|cfirst'. Scope: Global (g:). Default: copen.

  • g:coc_selected_text — The text used to replace the ${VISUAL} and ${TM_SELECTED_TEXT} placeholders of the next expanded snippet. Normally created by pressing <Plug>(coc-snippets-select) provided by the coc-snippets extension. The variable is removed after snippet expansion. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_selectmode_mapping — Add key mappings to make snippet select mode easier, the same as UltiSnips does. Default: 1. Example: snoremap <silent> <BS> <c-g>c snoremap <silent> <DEL> <c-g>c snoremap <silent> <c-h> <c-g>c snoremap <c-r> <c-g>"_c<c-r>. Scope: Global (g:). Default: 1.

  • g:coc_service_initialized — Is 1 when coc.nvim is initialized; used with the CocNvimInit autocmd. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_snippet_next — Trigger key for going to the next snippet position, applied in insert and select mode. Scope: Global (g:). Default: <C-j>.

  • g:coc_snippet_prev — Trigger key for going to the previous snippet position, applied in insert and select mode. Scope: Global (g:). Default: <C-k>.

  • g:coc_start_at_startup — Start the coc service on startup; use :CocStart to start the server when you set it to 0. Scope: Global (g:). Default: 1.

  • g:coc_status — Status string contributed by coc.nvim and extensions, used for the status line. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_status_error_sign — Error character used by coc#status(), default: E Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_status_warning_sign — Warning character used by coc#status(), default: W Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_terminal_height — Height of terminal window, default 8. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:coc_text_prop_offset — Start textprop id offset of highlight namespaces on Vim; change to another value to avoid conflict with other Vim plugins. Scope: Global (g:). Default: 1000.

  • g:coc_user_config — User configuration that is passed to the coc.nvim process during initialization; it has no effect when changed after coc.nvim starts. Prefer coc#config() unless coc.nvim is lazy loaded. Note: this configuration overrides the configuration from the user's settings file. Unless you need dynamic variables, using the settings file is recommended. Example: let g:coc_user_config = {} let g:coc_user_config['suggest.timeout'] = 500 let g:coc_user_config['suggest.noselect'] = v:true. Scope: Global (g:). Default: not stated in current coc.txt.

  • g:node_client_debug — Enable debug mode of the node client to check RPC messages between Vim and coc.nvim. Use the $NODE_CLIENT_LOG_FILE environment variable to set the log file, or get the log file after coc.nvim starts. On vim9, this variable also enables Vim's channel log; the log filepath is displayed on the screen after Vim starts. Scope: Global (g:). Default: 0.

  • g:WorkspaceFolders — Current workspace folders, used for restoring from a session file. Add set sessionoptions+=globals to your vimrc to restore globals on session load. Scope: Global (g:). Default: not stated in current coc.txt.

  • w:cocViewId — Exists on tree view windows to identify the kind of tree view. Scope: Window-local (w:). Default: not stated in current coc.txt.