VIM auto-completion with coc.nvim

rajikaimal

Rajika Imal

Posted on May 9, 2020

VIM auto-completion with coc.nvim

VIM is a modal text editor which gives bare minimal setup for text editing. However it's highly flexible and configurable with plugins. With few configurations, we can make VIM similar to VSCode. First you need to install a plugin managers. There are a bunch of plugin managers,

Installing any of the above managers is a straight forward task. After installing a plugin manager we are good to go 👏

Next up installing coc.nvim. Coc is an intellisense engine for VIM. (same as in VSCode) This uses language server protocol.

Intellisense

A prerequisite for Coc is Node.js as it's written in TypeScript. Navigate to vimawesome and copy install from script for the plugin manager you already installed earlier. Open your .vimrc and paste the copied plugin reference and run :source % and :PluginInstall to install the plugin.

From this point onwards we can use Coc intellisense, but there are a couple of commands that can be mapped from .vimrc to make it really convenient to be used quickly. Coc README offers a starting point for this configuration. This configuration can be copied and pasted to .vimrc. This will add few key mappings like gr, gi, gd for moving to method references, implementations, and definitions.

For every programming language Coc expects extensions to be installed. For an example for web development following command can be used.

:CocInstall coc-tsserver coc-html coc-css

This adds intellisense support TypeScript, HTML, and CSS.

Once that's done, that's all what we need for intellisense 🎉

Documentation
Documentation with K mapping

📄 Check out my not so minimal and messy .vimrc

💖 💪 🙅 🚩
rajikaimal
Rajika Imal

Posted on May 9, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related