Roberto Tonino

Neovim LSP: installing pyright does not work

Posted on:

You have nvim-lsp-config installed. You have null-ls installed. You have black and flake8 installed. Now you want to install pyright and use it as LSP with null-ls providing formatting and diagnostics. But it doesn’t work.

If you have installed pyright with pip (pip install pyright), there might be a small problem: you have to run at least once a pyright command, for instance:

pyright --version

You will notice that when running that command, pyright will install node and npm. WHY???

I’m sure there is some technical reason for this, but in any case I don’t want to have a duplicate installation of node. So, let’s all run together:

pip uninstall pyright

But now we are of course left with out pyright. As noted in the docs, it is also possible to install it via npm. Just run

npm i -g pyright

And again:

pyright --version

Now you will notice that there’s no installation of node of npm, I assume because we are using exactly those tools for installing pyright. Now open neovim and voilà, null-ls does its job and we can start coding again.