You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
huihao edited this page Oct 1, 2023
·
13 revisions
coc.nvim uses jsonc as configuration file format, the same as VSCode.
It's json 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:
autocmdFileTypejsonsyntaxmatchComment+\/\/.\+$+
to your .vimrc or init.vim.
Opening the configuration file
Use the command :CocConfig 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 configcallSetupCommandAbbrs('C', 'CocConfig')
Variables expand
Variables would be expanded in string values of configuration, supported variables:
${userHome} the path of the user's home folder
${cwd} current working directory of vim
some additional variables see:
:h coc-configuration-expand
Why use JSON?
LSP uses JSON for language server configuration.
Extensions can contribute 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 just after the settings file is saved, you don't need to restart vim or coc.
Configuration file resolve
To enable intellisense for coc-settings.json, install the json language extension coc-json by:
:CocInstall coc-json
In your vim.
Built in configurations
Checkout :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 section tsserver, typescript and javascript