DEV Community

Cover image for VIM auto-completion with coc.nvim
Rajika Imal
Rajika Imal

Posted on • Updated on

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

Top comments (5)

Collapse
 
eclecticcoding profile image
Chuck

I'm starting to set up Vim and this was exactly what I was looking for. Thanks.

Collapse
 
brandonskerritt profile image
Autumn

Hey! Just noticed this article didn't have a lot of love. Thanks for this! This came up on Google for me, and I used it. I didn't realise you had to use the .vimrc script, thanks!!

Collapse
 
rajikaimal profile image
Rajika Imal

Hey Brandon, glad you found the article useful, hopefully everything worked fine 😄 Here's my .vimrc if you you want to take a look just in case. (It's kind of messy though)

Collapse
 
t0maas profile image
T0maas

And what about nodejs, how to install nodejs autocompletion support?

Collapse
 
smalinux profile image
Sohaib Mohammed

Hi! What theme name you use? Thanks )