nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.41k stars 287 forks source link

Lightbulb should only be shown for quickfix code actions #1413

Open dhruvmanila opened 5 months ago

dhruvmanila commented 5 months ago

Apologies for highlighting this as an enhancement issue type but I think it's a bug. I don't use this plugin so I don't have the required information for a bug report. I assume that a lot of users of ruff-lsp in Neovim uses this plugin.

We received an issue around the lightbulb functionality that it's always shown even if the code actions are no-op: https://github.com/astral-sh/ruff-lsp/issues/91. This is the case for source level code actions.

To give some context, what ruff-lsp does is provide the source level code action without an edit to inform the client that the server supports it but will compute the edit lazily via the codeAction/resolve request. This means that when a client requests for a code action, it will always contain the source code actions even if there's nothing to do. So, the lightbulb is shown for every line.

My suggestion and what VS Code does as well is to use the only option to filter and get the quickfix code actions to show the lightbulb. Here's a reference to the VS Code implementation: https://github.com/microsoft/vscode/blob/246d700c4604eb5ebdbb561a1a86562bf9217a62/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts#L619-L649. Refer to line 639 where it filters out the code actions and here's it translates to the CodeActionContext before sending the request.