I needed a single location to install my LSPs and other NPM related tools for Neovim, which allows for ‘locked down’ versions and without the need to install NPM packages globally.

Like many large workplaces, mine has strict rules on what you can and can’t ‘use’ when it comes to your text editor and associated tooling; versions are scanned and locked to a particular version.

In addition, because of all the lovely spyware admin software that is installed on my work system, performing a global install of a Language Server can be fraught. Using a nice tool like Mason is also problematic so my plan was this…

Define a destination on my system that I knew would be accessible from my $HOME and install all my packages there. Then, add this location to my $PATH so that Neovim can ‘see’ it.

I chose to create and use the folder .local/share/nvim/spec. Then for any package I want to add for Neovim, I head there and do my (non global) install there.

To add that location to my path, for NPM packages, I added this entry to my .zshrc:

export PATH="$HOME/.local/share/nvim/spec/node_modules/.bin:$PATH"

That meant that LSPs like vscode-css-language-server can now be used without fuss. Same deal with TypeScript and Stylelint, while things like Stylelua I tend to install via Homebrew, which doesn’t usually cause me any issues.

Note: it might be necessary to add a package.json to the folder you create, otherwise NPM will go up the folders until it finds a package.json, and install it there instead.

Learn to use CSS effectively, 'Enduring CSS' is out now

Get $5 off HERE ↠

Write and maintain large scale modular CSS and embrace modern tooling including PostCSS, Stylelint and Gulp