astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.5k stars 1.08k forks source link

[nvim/server] code action popup menu does not appear #11458

Closed baggiponte closed 5 months ago

baggiponte commented 5 months ago

Ciao!

I am using neovim with ruff (and/or ruff-lsp) as LSP server, in tandem with pyright. Yesterday I update to nvim 0.10.0 and noticed ruff odes not display the code action popup menu (vim.lsp.buf.code_action()). I was just using ruff, so I reinstalled ruff-lsp and in the logs found this:

[ERROR][2024-05-17 11:38:37] .../vim/lsp/rpc.lua:770    "rpc"   "/Users/luca/.local/share/nvim/mason/bin/ruff"  "stderr"    "  10.131295s ERROR ruff_server::server::api An error occurred with result ID 4: failed to deserialize diagnostic data: missing field `range`\n"

[ERROR][2024-05-17 11:38:37] .../vim/lsp/rpc.lua:770    "rpc"   "/Users/luca/.local/share/nvim/mason/bin/ruff-lsp"  "stderr"    "Exception occurred for message \"3\": KeyError: 'location'\nTraceback (most recent call last):\n  File \"/Users/luca/.local/share/nvim/mason/packages/ruff-lsp/venv/lib/python3.12/site-packages/pygls/protocol/json_rpc.py\", line 194, in _execute_request_callback\n    self._send_response(msg_id, result=future.result())\n                                       ^^^^^^^^^^^^^^^\n  File \"/Users/luca/.local/share/nvim/mason/packages/ruff-lsp/venv/lib/python3.12/site-packages/ruff_lsp/server.py\", line 1000, in code_action\n    edit=_create_workspace_edit(\n         ^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/Users/luca/.local/share/nvim/mason/packages/ruff-lsp/venv/lib/python3.12/site-packages/ruff_lsp/server.py\", line 1490, in _create_workspace_edit\n    line=edit[\"location\"][\"row\"] - 1,\n         ~~~~^^^^^^^^^^^^\nKeyError: 'location'\n"

The first log should be the error within ruff server, the second within ruff-lsp. Am finding it really hard to dissect, any suggestion on how I can improve the report? Thanks! I guess I should s/o @dhruvmanila

baggiponte commented 5 months ago

Don't know why but this solved itself.

dhruvmanila commented 5 months ago

Thank you for updating the issue. Feel free to re-open if you face this problem again, I can debug it.

baggiponte commented 5 months ago

Thanks for your answer! Now I have this small issue:

image

Set aside the error message (don't know what this is due to), I see a duplicated message for errors 1-2 and no option to ignore the rule. Maybe nvim can only display 4 options?

dhruvmanila commented 5 months ago

I don't think there's any limit as to how many code actions Neovim can display. I'm not exactly sure what I'm seeing here. Is it a notification popup like the one in nvim-notify? Is it some other plugin which shows a floating window and then you type an appropriate number?

baggiponte commented 5 months ago

I don't think there's any limit as to how many code actions Neovim can display. I'm not exactly sure what I'm seeing here. Is it a notification popup like the one in nvim-notify? Is it some other plugin which shows a floating window and then you type an appropriate number?

Ops, sorry. It's noice.nvim. It uses notify under the hood. It might simply be an error on their side. Will open a new issue if I see that pop up again 😊