4

Adding to $PATH for a central location for Neovim/NPM tools

 1 year ago
source link: https://benfrain.com/adding-to-path-for-a-central-location-for-neovim-npm-tools/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Adding to $PATH for a central location for Neovim/NPM tools

22.03.2023 0 comments
0 days since last revision. Content should be accurate.

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.

If you enjoyed this post and/or it was useful, Say thanks with a coffee. 🙏

Latest Book Responsive Web Design with HTML5 and CSS

The 4th Edition of the best—selling 'Responsive Web Design with HTML5 and CSS'.

Amazon Packt


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK