Fix neovim coc-metals for Scala installation under FreeBSD

For some time now the usage of metals for Scala development is no longer a choice for the brave but could be considered the “should be default” variant. However the installation for the neovim plugins has changed from using coursier bootstrap to something supposed to be easier. But at least under FreeBSD I ran into some issues. So here is a workaround to get a clean installation.

I won’t talk about setup here because I assume that you already have that and know what you’re doing.

The documentation says you should install the coc-metals plugin directly via coc which means entering :CocInstall coc-metals in your neovim command line. Another approach is to include it directly in your Vim-Plug configuration and use the :PlugInstall command of it.

Both approaches failed for me under FreeBSD, each one with a different error message.

The CocInstall way bailed out with something like this:

[coc.nvim] Error on install coc-metals: Error: EPERM: operation not permitted, unlink '/tmp/coc-metals-s4W6ca'

Using Vim-Plug gives some more messages ending in the following:

[coc-nvim] extension "coc-metals" doesn't contain main file ~/.config/nvim/bundle/coc-metals/lib/index.js.

Install via yarn

To get it working I had to manually install the plugin via the yarn command. This is done the following way:

% cd ~/.config/coc/extensions
% yarn add coc-metals

If you get weird errors then please read on. ;-)

Cleaning your installation in case of errors

Please note that if you get errors you might need to clean your installation beforehand. The cleaning can be done this way:

% rm -rf ~/.config/coc
% rm -rf ~/.config/nvim/bundle

Afterwards start neovim and initialise your plugins (for example :PlugInstall if using Vim-Plug). Then you can try again.

Jens Grassel Written by:

Solving problems and burning chrome for fun and profit.