astral-sh / ruff-lsp

A Language Server Protocol implementation for Ruff.
Other
1.33k stars 46 forks source link

Unable to see ruff CodeActions #482

Closed AnirudhG07 closed 2 months ago

AnirudhG07 commented 3 months ago

I just downloaded the ruff-lsp in my Neovim. I am able to see formatting, sorting of imports, linting, etc. But i am unable to see CodeActions as the snippets provides(as it says it will automatically come)...

Can you help me? Here is my link to neovim LSP dotfiles.

Version ruff: v0.6.1 Ruff should work anywhere on my machine, so i have not made any ruff.toml, using whatever is made(if made, not sure) by default.

AnirudhG07 commented 3 months ago

Also is there no :Ruff option or similar i can use. If it exists, pls share. If not, it would be great if you could make that for neovim.

dhruvmanila commented 3 months ago

Hey,

We now recommend to use the native server (not ruff-lsp) for which you can find the setup docs at https://docs.astral.sh/ruff/editors/setup/#neovim for Neovim. It's implemented within Ruff itself so you don't need to install a separate package. If you've ruff binary installed, then the server is available to you and you just need to configure nvim-lspconfig to do that.

Looking at your dotfiles, you'd just need to change ruff_lsp to ruff (https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ruff).

AnirudhG07 commented 3 months ago

Hi. thanks for your fast response. i have change ruff_lsp to ruff. I am still now getting Code Actions. The behaviour didnt change. Can you explain me how to get it please? It would be great to get things fixed within nvim. (I have updated my dotfiles, you can check)

Also like lua_ls has auto indentation when i write and save. Is this behaviour shown by ruff? or any other similar tool for python?

AnirudhG07 commented 3 months ago

Also i saw this. Seems very elegant to me. Is this for only coc.nvim or can be used in general?

dhruvmanila commented 2 months ago

You'd need to ask the server for the code action which can be done by vim.lsp.buf.code_action (https://neovim.io/doc/user/lsp.html#vim.lsp.buf.code_action()).

AnirudhG07 commented 2 months ago

There is an issue with ruff. Ruff made my python code working VERY slow. Like when I press :, it would take 5-6 seconds to just open it. for small files it worked fine, but for bigger files, it was very slow. I switched back to previous ones, which we black, pylint, etc. and the speed came back for python.

I initially thought something was wrong with my neovim. so I reinstalled it, restarted my comp but the issue for slowness persisted. As mentioned above, when I removed ruff from LSP, the speed of general neovim commands came back. Please look into it.

dhruvmanila commented 2 months ago

Ruff made my python code working VERY slow. Like when I press :, it would take 5-6 seconds to just open it. for small files it worked fine, but for bigger files, it was very slow.

What would take that much time to open? Are you referring to the completion for the Neovim commands? That's not done by Ruff, it must be one of the plugins.

Regardless, this seems unlikely to be caused by Ruff because we don't support autocompletion.

Is your original issue resolved about code actions?

AnirudhG07 commented 2 months ago

Yes code actions is taken care of. Thanks for the reference!