Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No code actions available when hovered over certain warnings #94

Closed
patrickarmengol opened this issue Apr 15, 2023 · 11 comments
Closed
Labels
bug Something isn't working

Comments

@patrickarmengol
Copy link

When hovering over certain warnings, like F401, no code actions are available. This seems to be unintended as the first example gif in the readme (https://github.com/charliermarsh/ruff-lsp#quick-fix-actions-for-auto-fixable-violations-like-unused-imports) shows available code actions when hovering F401.

Environment: neovim 0.9.0, ruff-lsp 0.0.24

Steps to reproduce:

  1. Open a python file
  2. Scroll over or write in an unused import to create a F401 warning.
  3. Try to call code actions :lua =vim.lsp.buf.code_action()

screenshot

Another diagnostic code that causes this issue is F821(undefined name). Per #91 (comment) this may affect quite a few more types of warnings.

@charliermarsh
Copy link
Member

I just tested this locally in Neovim and it worked correctly for me with v0.8.1, AFAICT:

Screen Shot 2023-04-22 at 7 36 48 PM

I'll try upgrading to 0.9.0.

@charliermarsh
Copy link
Member

Hmm, ok, still seems to work on 0.9.0. Do you have other plugins installed, anything else that could be impacting this?

@patrickarmengol
Copy link
Author

Hmm, ok, still seems to work on 0.9.0. Do you have other plugins installed, anything else that could be impacting this?

Not sure what it could be. I disabled pyright that was running beside it. I commented out the ruff-lsp lines from lspconfig.

Just to give some background, I'm running astronvim. The base config files for lsp stuff (utils/lsp.lua and plugins/configs/lspconfig.lua) don't seem to reveal anything that could be causing this (at least to my eyes).

Another user on the astronvim discord reported the same issue too, so perhaps it's an "us" problem.
screenshot

Though I wonder why #91 (comment) ran into the same problem.

I'll try to mess around a bit more to isolate it.

@patrickarmengol
Copy link
Author

patrickarmengol commented Apr 26, 2023

Ok, looks like I messed up when choosing an example warning to represent the issue as F401 was marked under unfixable in the ruff settings for the default hatch-generated pyproject.toml.

Still, this occurs for other non-fixable warnings like:

F821 (undefined name)
screenshot

F704 (yield outside function):
screenshot

@charliermarsh
Copy link
Member

Ah no worries. I think those two errors aren't actually fixable though, so it seems right for there to be no code actions available.

@charliermarsh charliermarsh added the question Further information is requested label Apr 26, 2023
@patrickarmengol
Copy link
Author

patrickarmengol commented Apr 26, 2023

Ah no worries. I think those two errors aren't actually fixable though, so it seems right for there to be no code actions available.

Should file-wide actions (like fix-all and org-imports) still be unavailable though? They are available on empty lines and other unrelated fixable warnings. Sorry I'm not sure how code actions for other LSPs usually work.

@charliermarsh
Copy link
Member

Oh, hmm, maybe? I'd say yes? But I'm not 100% certain either, it could vary from client to client, but I'm confused as to why it would suppress them there.

@patrickarmengol
Copy link
Author

patrickarmengol commented Apr 26, 2023

I'm coming from VSCode, where the actions are available in such situations, so I thought it was strange. Also ran into it when testing out performing code actions on save in order to auto-sort imports in nvim. IMO they should be available, but not sure how to do so for nvim. Feel free to close this issue, unless you think it could be fixed from the language server side and not the client. Thanks.

@burnettk
Copy link

I took the time to create a minimal repro for an issue that I saw that may be an example of this: https://github.com/burnettk/assorted-repro-scenarios/tree/main/ruff-lsp-bug-repro. Basically, with the following code, even though there are linting issues on both lines. there are no code actions for line 1, but there are code actions for line 2:

def sureEnough():
    a = 1
    print("I'm sure")

sureEnough()

@dhruvmanila
Copy link
Member

dhruvmanila commented Jun 11, 2023

I'm pretty confident it's the same issue: #128

It should be fixed on HEAD. Let me do a quick test with the examples mentioned in this issue. @charliermarsh we would probably need to make a patch release.

@dhruvmanila
Copy link
Member

Yeah, it's the same issue. It's fixed with #129

@dhruvmanila dhruvmanila added bug Something isn't working and removed question Further information is requested labels Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants