helix icon indicating copy to clipboard operation
helix copied to clipboard

chore: add ruff and jedi lsp servers

Open nikaro opened this issue 1 year ago • 5 comments

Ruff provide a server command that starts a LSP server: https://docs.astral.sh/ruff/editors/#language-server-protocol

nikaro avatar Sep 04 '24 14:09 nikaro

For python to be set up to use this out of the box, it needs to be added to the language-servers list.

https://github.com/helix-editor/helix/blob/41db5d735eae03be9a69b1136844dac642484ed8/languages.toml#L847-L857

RoloEdits avatar Sep 05 '24 23:09 RoloEdits

Do we want it enabled by default? pylsp relies on plugins for diagnostics, etc. and there is a ruff one. Won't it cause duplicate diagnostics messages?

My usage is to replace pylsp with a combination of ruff, jedi and basedpyright LSP servers:

[[language]]
name = "python"
language-servers = ["ruff", "jedi", "basedpyright"]

[language-server]
jedi = { command = "jedi-language-server" }
ruff = { command = "ruff", args = ["server"] }

nikaro avatar Sep 06 '24 07:09 nikaro

Following my other comment in #11631, the order of the servers written dictates the suggestion order you see in the editor. Perhaps it can be assumed that if you install other lsps besides pylsp you would rather those be used first?

[[language]]
name = "python"
language-servers = ["ruff", "jedi", "basedpyright", "pylsp"]

In the code actions popup, you would see suggestions for ruff first, followed by jedi, etc. falling back to pylsp with whatever configuration the user would have set up. There are a lot of assumptions here on usage, but I think its sound reasoning? Perhaps others who use python with a more diverse set of tools could offer more clarity. I'm pretty basic with only ruff and basedpyright myself.

RoloEdits avatar Sep 06 '24 08:09 RoloEdits

You might want to combine the changes in this PR and #11631 since the changes overlap and will conflict with each other if done in separate PRs

To fix the docs CI you can run cargo xtask docgen and commit the results

the-mikedavis avatar Sep 06 '24 14:09 the-mikedavis

This is done, thank you for the guidance! 🙏

nikaro avatar Sep 06 '24 20:09 nikaro