nova-python / Python.novaextension

Python for Nova
MIT License
11 stars 1 forks source link

Integrate `pylyzer` to speed up code completion #8

Open realCrush opened 2 months ago

realCrush commented 2 months ago

Currently, the plugin uses Pyright as the LSP. Although Pyright is powerful, it's still slow, especially noticeable during code completion. There is a perceptible delay between typing a character and seeing the completion suggestions (as for comparison, Nova's built-in Python completion is almost instantaneous). Therefore, I found an LSP called Pylyzer, which claims to be 100 times faster than Pyright. Pylyzer is written in Rust and boasts very high performance (similar to Ruff, though Ruff does not support type checking). Please consider supporting Pylyzer in the plugin, as I believe it will greatly enhance the Python coding experience!

dcwatson commented 1 month ago

That definitely looks interesting! If I do expand the LSP support beyond Pyright, it will likely be to make a more generic way to use whatever you want, so I'll keep this one in mind.

I probably won't support this "officially" though, there are a couple of red flags for me:

  1. It looks to be a single developer - not disqualifying on its own, but there are better supported and more full-featured tools available (despite being slower), so its hard to commit to maintaining support for something like this
  2. The way it does the type-checking seems a bit roundabout and fragile to me: "pylyzer converts Python ASTs to Erg ASTs and passes them to Erg's type checker. It then displays the results with appropriate modifications"
realCrush commented 1 month ago

That definitely looks interesting! If I do expand the LSP support beyond Pyright, it will likely be to make a more generic way to use whatever you want, so I'll keep this one in mind.

I probably won't support this "officially" though, there are a couple of red flags for me:

  1. It looks to be a single developer - not disqualifying on its own, but there are better supported and more full-featured tools available (despite being slower), so its hard to commit to maintaining support for something like this
  2. The way it does the type-checking seems a bit roundabout and fragile to me: "pylyzer converts Python ASTs to Erg ASTs and passes them to Erg's type checker. It then displays the results with appropriate modifications"

By the way, I'm not sure if the significant delay in code completion based on pyright is specific to me, I can't figure out why it happens. Using pyright with VSCode+Pylance shows almost no delay. I'd like to know if there's a way to reduce the code completion delay in Nova through some configurations of pyright-langserver. Is the delay caused by Nova's shortcomings in LSP support, is it unavoidable? 🤔