Setting up Neovim plus Coc for Python, C++, Go, Rust and javascript

There is no doubt, coding is getting more complex nowadays. I have to code in Python, C and C++ and I have usually used vi for small edits. For production I have used PyCharm, for C, C++ Visual Studio.

Visual Studio Code is a great editor with multiple extensions to support different languages. Although, I am used to vim and I always tried to setup intellisense to support different languages.

I like to use Visual Studio Code, however, I feel more productive with vi editor. In this post I’m setting up NeoVim with Coc to code in my favorite languages. In the past I tried vim with different plugins to have code completion.

Finally, I think NeoVim plus Coc is a good option to use vim.

COC requires nodejs and yarn. So, first step is to install those tools:

Install nodejs, create node repo:

curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash 

Install nodejs

sudo dnf install nodejs

Install yarn:

Create yarn repo with

[yarn]
name=Yarn Repository
baseurl=https://dl.yarnpkg.com/rpm/
enabled=1
gpgcheck=1
gpgkey=https://dl.yarnpkg.com/rpm/pubkey.gpg

Install yarn

sudo dnf install yarn

Install Vim Plug:

sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

Setup Plugin Manager in your init.vim file:

Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}

Launch NeoVim and manage code completion from inside NeoVim. This is what I like more about COC, you can install all the code completion extensions using CocInstall:

Neovim. Show Installed Coc Extensions
CocInstall coc-rust-analyzer and others....
CocInstall Output

PYTHON

Notes: Set interpreter to python 3. Optional use Jedi or language server. I’ll use Jedi:

I had to remove python3-jedi package from Fedora and install it with pip3. You can use CocConfig to setup json file and toggle jedi or language server.

Code Completion JEDI
Code Completion JEDI disabled

C++

Code completion using clangd

RUST

You need to setup Rust-Analyzer with CocConfig

GO

Code completion using gopls

SetUp Go settings with CocConfig.

My coc-settings.json:


From CocConfig

Leave a Reply

Your email address will not be published. Required fields are marked *