Skip to content

Using the configuration file

Qiming Zhao edited this page Aug 3, 2026 · 14 revisions

coc.nvim uses jsonc as the configuration file format, the same as VSCode. It's a JSON format that supports comments, like:

{
  // my variable
  "key.sub-key": "value"
}

To get correct comment highlighting, make sure you use a recent Vim (8.2.3117 or later) or NeoVim (0.6.0 or later) version. Alternatively you can install vim-jsonc (which has built-in support for coc-settings.json), or even simply add:

  autocmd FileType json syntax match Comment +\/\/.\+$+

to your .vimrc or init.vim.

Opening the configuration file

Use the :CocConfig command to open your user configuration file. You can create a shortcut for the command like this:

function! SetupCommandAbbrs(from, to)
  exec 'cnoreabbrev <expr> '.a:from
        \ .' ((getcmdtype() ==# ":" && getcmdline() ==# "'.a:from.'")'
        \ .'? ("'.a:to.'") : ("'.a:from.'"))'
endfunction

" Use C to open coc config
call SetupCommandAbbrs('C', 'CocConfig')

Variable expansion

Variables are expanded in string values of the configuration. Supported variables:

  • ${userHome}: the path to the user's home folder
  • ${cwd}: the current working directory of vim

For additional variables, see:

:h coc-configuration-expand

Why use JSON?

  • LSP uses JSON for language server configuration.
  • Extensions can contribute a JSON schema for JSON validation.
  • coc-json can provide completion and validation for the settings file, which makes configuration much easier and more reliable.
  • Most configurations take effect as soon as the settings file is saved; you don't need to restart vim or coc.

Resolving the configuration file

To enable IntelliSense for coc-settings.json, install the JSON language extension coc-json by running:

:CocInstall coc-json

in your vim.

Built-in configurations

Check out :h coc-config for all built-in configurations.

Extension configuration

Just like VSCode, each coc.nvim extension can contribute configuration sections, for example:

  • coc-tsserver uses the tsserver, typescript, and javascript sections
  • coc-json uses the json section

To see the available options for existing configurations, try completion in coc-settings.json:

screen shot 2018-07-13 at 2 17 26 pm

REPL

Clone this wiki locally