Coc.nvim configuration: Difference between revisions

From wikinotes
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
{| class="wikitable"
{| class="wikitable"
|-
|-
| <code>~/.config/nvim/coc-settings.json</code>
| <code>~/.config/nvim/coc-settings.json</code> || coc and extension configuration
|-
|-
|}
|}
</blockquote><!-- Locations -->
</blockquote><!-- Locations -->


= Syntax =
= coc-settings.json =
<blockquote>
<blockquote>
JSONc (supports comments)
This file contains configuration for all coc extensions, in addition to coc itself.<br>
It is expressed in JSONc (json + comments).


</blockquote><!-- Syntax -->
If you have installed <code>coc-json</code>, the configuration options will be auto-completed!


= Keybindings =
At any time you can open this with <code>:CocConfig</code>.
</blockquote><!-- coc-settings.json -->
 
= .vimrc =
<blockquote>
== Options ==
<blockquote>
<syntaxhighlight lang="vim">
" change where coc settings saved to (useful for work-env/os dependent configurations)
let g:coc_config_home = $HOME."/.config/nvim"
 
" installed extensions
let g:coc_global_extensions = ["coc-json", "coc-git", ...]
</syntaxhighlight>
</blockquote><!-- Options -->
 
== Command Interface ==
<blockquote>
=== Plug Functions ===
<blockquote>
<blockquote>
coc.nvim does not provide function calls, they direct you to bind hotkeys instead.
coc.nvim does not provide many commands, they direct you to bind hotkeys to plug-functions instead.
<syntaxhighlight lang="vim">
<syntaxhighlight lang="vim">
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gd <Plug>(coc-definition)
Line 23: Line 42:
nmap <silent> gr <Plug>(coc-references)
nmap <silent> gr <Plug>(coc-references)
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- keybindings -->
 
You can create vim commands to mirror these functions though if you'd like
<syntaxhighlight lang="vim">
command CocRename silent exec "normal \<Plug>(coc-rename)"
</syntaxhighlight>
</blockquote><!-- plug functions -->
 
=== Coc-Commands ===
<blockquote>
It is also good to be aware that extensions may provide their own language-specific commands.<br>
These can be searched, or tab-completed.
 
<syntaxhighlight lang="vim">
:CocList commands              " fuzzy-search commands
:CocCommand solargraph.search  " search sourcecode
</syntaxhighlight>
</blockquote><!-- CocCommand -->
</blockquote><!-- command interface -->
</blockquote><!-- vimrc -->

Latest revision as of 18:28, 28 December 2021

Locations

~/.config/nvim/coc-settings.json coc and extension configuration

coc-settings.json

This file contains configuration for all coc extensions, in addition to coc itself.
It is expressed in JSONc (json + comments).

If you have installed coc-json, the configuration options will be auto-completed!

At any time you can open this with :CocConfig.

.vimrc

Options

" change where coc settings saved to (useful for work-env/os dependent configurations)
let g:coc_config_home = $HOME."/.config/nvim"

" installed extensions
let g:coc_global_extensions = ["coc-json", "coc-git", ...]

Command Interface

Plug Functions

coc.nvim does not provide many commands, they direct you to bind hotkeys to plug-functions instead.

nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

You can create vim commands to mirror these functions though if you'd like

command CocRename silent exec "normal \<Plug>(coc-rename)"

Coc-Commands

It is also good to be aware that extensions may provide their own language-specific commands.
These can be searched, or tab-completed.

:CocList commands              " fuzzy-search commands
:CocCommand solargraph.search  " search sourcecode