foundev.github.io

coc-vim the perfect compliment to vim

Vi(m) has been the reliable editor of my career. I’ve either used Vi bindings in my IDEs or used Vim itself for my editor of choice. Some of this was because I was working on servers a lot during my career as an admin, sometimes it was because the dynamic languages I liked using don’t or didn’t have great IDE support so may as well use something I’m familar with and is light weight.

lightweight

This is the best part of Vim for me, there is no giant pausing or waiting for the IDE to respond that I so often have happen with IDEs. Some of this is my preference for lightweight portable hardware, but some of it is the larger code bases I’ve had to tackle in my career. Those same code bases are no issue in something “dumb” like vim, and I can still do pretty complex text munging and chopping. I will pull out the IDE for bigger refactoring jobs but not use it for minute by minute code editing, partiularly in code bases where I have the APi well understood.

Intellisense the IDE advantage

However, in new languages, or new code bases, the lack of really good or really easy to setup intellisense has been problematic, so again, I’ll pull out the IDE when I’m just learning a language or just getting started on a new project and I quickly want to get through the code base. This is fine, and I can be pretty productive with most IDEs, but on more than one occasion when we’ve been against a deadline, I find myself reaching for vim so I can disect and chip up big blocks of text and write without pausing or waiting on the IDE to think through all this change.

There has been various attempts over the years to add these kind of smarts to vim and there are too many to list or get into, but from ctags (and the numerous forks), bridges to IDEs like eclim, a few language specific engines nothing seems to have ‘stuck’. Lately there have been various LSP servers and attempts to integrate those in with vim and they work pretty well. For example I’ve overall had very good luck with gopls and go.

COC

However, this week I found COC and I have to say I’m completely blown away. Completion is instantaneous and obvious. I’m able to navigate code bases with ease and I get access to a host of languages with full blown language servers.

This makes vim closer to a full IDE without all the downsides that I feel I’ve had. There a ton of extensions that are easy enough to install and so far have all been pretty good. The Metals integration is probably as good as the vscode equivalent. Note this is the early days and I’ve had other really promising projects fizzle out with time, but at this second this is the happiest I’ve ever been with my code editing environment.