VimPlugin: Coc.nvim: Difference between revisions
From wikinotes
(→Usage) |
|||
Line 112: | Line 112: | ||
= Usage = | = Usage = | ||
<blockquote> | <blockquote> | ||
Builtin Commands | |||
<syntaxhighlight lang="vim"> | <syntaxhighlight lang="vim"> | ||
CocInstall coc-python | CocInstall coc-python " install a language | ||
CocUninstall coc-python " uninstall a language | |||
CocOutline " tagbar-like outliner | |||
</syntaxhighlight> | |||
Custom Commands (derived from plug functions) | |||
<syntaxhighlight lang="vim"> | |||
" ex: command CocRename silent exec "normal \<Plug>(coc-rename)" | |||
" Introspection (src, packages) | |||
CocDefinition " go to where variable assigned | |||
CocTypeDefinition " go to where variable type defined | |||
CocImplementation | |||
CocReferences " show uses of variable | |||
CocShowdocumentation " show docs | |||
" Formatting | |||
CocFormatBuffer " format file | |||
CocFormatSelected " format selection | |||
" Debugging | |||
CocInfo " show nvim, coc, lsp info | |||
CocOpenLog " show log | CocOpenLog " show log | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Usage --> | </blockquote><!-- Usage --> |
Revision as of 20:14, 27 December 2021
coc.nvim aims to be intellisense (visualstudio) for vim.
- autocompletion
- outliner
- refactor-rename
- goto
- show-references
WARNING:
coc.nvim DOES NOT play nice with other autocompleters.
Documentation
Locations
~/.config/nvim/coc-settings.json
config ~/.config/coc/extensions/node_modules/${plugin}
plugins installed here ~/.config/coc/memos.json
persisted plugin data
Languages
Languages can be installed dynamically with
:CocInstall coc-python
or automatically likePlug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'}
.
python unmaintained coc-python python active coc-pyright sh/bash active coc-sh ruby/rails active coc-solargraph graphql active coc-graphql
Install
# archlinux sudo pacman -S \ nodejs \ npm # macos brew install node.js \ npm npm install -g neovim" install coc Plug "https://github.com/neoclide/coc.nvim", {'branch': 'release'} " install coc languages " NOTE: technically this is supposed to work, but it doesn't for all languages " Plug 'https://github.com/neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'} if !(isdirectory($HOME."/.config/coc/extensions/node_modules/coc-sh")) CocInstall coc-sh endifNOTE:
Officially, installing servers can be done from vim-plug, but I have not had success with this.
CocInstall
works every time. It's probably best to check for files on disk.
Configuration
Keybindings
coc.nvim does not provide function calls, they direct you to bind hotkeys 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)
Usage
Builtin Commands
CocInstall coc-python " install a language CocUninstall coc-python " uninstall a language CocOutline " tagbar-like outlinerCustom Commands (derived from plug functions)
" ex: command CocRename silent exec "normal \<Plug>(coc-rename)" " Introspection (src, packages) CocDefinition " go to where variable assigned CocTypeDefinition " go to where variable type defined CocImplementation CocReferences " show uses of variable CocShowdocumentation " show docs " Formatting CocFormatBuffer " format file CocFormatSelected " format selection " Debugging CocInfo " show nvim, coc, lsp info CocOpenLog " show log
Troubleshooting
:CocInfo " print debug info