All Projects → rstacruz → Vim Coc Settings

rstacruz / Vim Coc Settings

My Vim settings for setting it up like an IDE

Rico's Neovim + Coc settings

👋 Hey there, here's my setup on how I use coc.nvim to make my Vim work like an IDE.

I've been VSCode, Atom, Sublime, and other modern editors. They are fantastic! I love how I get automatic type hints, amazing auto-complete, inline documentation, and many things that Vim users may consider to be frivolous luxuries.

They're no Vim, though. VSCode's Vim emulation can be a bit slow (try doing 9j on vscode-vim, and try it on Vim itself). They also take a lot of memory, which can be too much for 4GB/8GB laptops.

Since coc.nvim came around, there's no need to compromise anymore. You can get IDE-like features in Vim, and here's how I did it!

Install Vim (and friends)

You need neovim (or vim 8.1+), nodejs and yarn. Coc's internals runs on Node.js.

Platform Command
macOS (via Homebrew) brew install nodejs neovim yarn
Arch Linux sudo pacman -Syu nodejs neovim yarn

I suggest using vim-plug to manage your dependencies.

Copy from the files here

The files in this repo are things you can merge into your Vim/Neovim configuration.

File Desrcpition
~/.config/nvim/init.vim List of plugins to load
~/.config/nvim/coc-settings.json Settings for coc-nvim
~/.config/nvim/after/plugin/coc.vim Key bindings and other Coc settings

If you're using Vim instead of Neovim, take what's in init.vim and place it in ~/.vimrc, and the config folder is ~/.vim instead of ~/.config/nvim.

Also see

Many of the configuration are lifted from almost-verbatim from Coc documentation. I highly recommend checking those out too.

Key bindings

See after/plugin/coc.vim for a full list of key bindings. Below are some of the features that I find to be most useful:

Key Description
ghShow hint/documentation
Shows a hint for whatever's on the cursor. This means type definitions, JSDoc comments, and documentation (when available). Similar to VSCode's mouse over functionality.
space c rRename symbol
Rename whatever is on the cursor. Similar to VSCode's Rename Symbol command (F2).
ctrl-nCode completion
Code completion just happens. ctrl-n and ctrl-p are default Vim key bindings for browsing through code completions.
space-cc-prettierPrettier
Prettier formatting happens on every save, automatically! You can also trigger it manually via invoking Coc commands via space-c-c.
space c cShow available commands
Fix tslint problems automatically, run Prettier manually, auto-fix eslint, and more.
-
space c xEnable/disable extensions
If you don't need tsserver in your current project, you can temporarily disable them.
-
space c lList errors
When you find errors, use this to shown them all
-

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].