LSP for Python?

I’m considering switching from vim with syntastic to neovim, so I can use an LSP and telescope.

What are people’s favorite LSP’s for Python? This URL:

…lists four of them.

This list:
https://langserver.org/#implementations-server
…appears to show six options.

There’s also this (pretty dated) Reddit thread:

Pyright is the best one in my opinion. I think it’s also the default one in the neovim docs.

Two things about this:

  1. It sounds like Microsoft plans to deprecate pyright eventually.
  2. It’s probably quite nice for small to medium-sized projects, but for big ones it’s kinda slow. And I’m told that throwing more CPU cores at Pyright won’t solve the problem.

Where do you get that idea from? It’s the backend of pylance (not open source)

Right. I’m aware that pylance uses pyright (basically extends it) but pyright is the available lsp for vim and pylance is restricted to vscode. Where does it say pyright is being deprecated? I don’t see it.

The future of the Microsoft Python Language Server

Pylance represents a drastic improvement for the Python experience in Visual Studio Code, to which our team has dedicated months of work. The new, free language server offers increased performance and many more features. Because of that, our team’s focus will shift to Pylance to continue evolving it.

In the short-term, you will still be able to use the Microsoft Python Language Server as your choice of language server when writing Python in Visual Studio Code.

Our long-term plan is to transition our Microsoft Python Language Server users over to Pylance and eventually deprecate and remove the old language server as a supported option.

-----.

More to the point, pyright is just too slow on big projects.

Sounds like the good old embrace, extend, extinguish.

I hope that just means pyright won’t be a thing on vscode not pyright is gone completely.

You can’t use pylance with other editors

Old, maybe. Good? No.

Microsoft Python Language Server and Pyright are different language servers. And as far as I know, they do not plan to deprecate Pyright.

https://github.com/Microsoft/python-language-server

https://github.com/microsoft/pyright

1 Like

I tried pyright for a while, but it was just too slow to be practical.

I’m now using GitHub - python-lsp/python-lsp-server: Fork of the python-language-server project, maintained by the Spyder IDE team and the community with GitHub - charliermarsh/ruff: An extremely fast Python linter, written in Rust.

As I understand it, Pyright is primarily a static type checker rather than a full-featured LSP server, AFAIK. Unless you just want static type checking, you probably want to consider a more general-purpose and pluggable LSP server.

Previously the de-facto “standard” implementation for Python was Palantr’s python-language-server, but they basically stopped maintaining it years ago. The Spyder team (of which I’m a member, but not directly involved with LSP stuff) stepped in to help maintain it as we were given commit rights, and eventually we ended up having to fork it to python-lsp-server which has become its successor that pretty much everything maintained has switched to. It now has a number of first-party plugins for a variety of popular linters and tools, including Ruff, Mypy, Black, Cookiecutter, etc. in addition to built-in support for Jedi, Rope, etc.

I wound up using ruff_lsp.