Closed ouuan closed 3 months ago
Hello, Which LSP do you use?
Which LSP do you use?
In the title, rust analyzer.
Maybe did you configure your LSP ? I have the default config, and it did not shows the same code actions as yours:
I'm not sure, but the problem also exists in your second screenshot.
It should be good now. Can you test it please ?
There is an extra new line in the diff.
It should now be ok (I hope) as of commit https://github.com/rachartier/tiny-code-action.nvim/commit/8fb55da53c5ed3f5a25ad07916d40f50b0b59172:
There is an extra new line in the diff.
This one is still the same. I'm not sure why you are seeing a different list of available code actions. I'm using rust-analyzer 1 (4afe0d5393 2024-07-21)
and cargo 1.80.0 (376290515 2024-07-16)
.
I see that this plugin uses custom logic to parse the language server outputs. Can we use vim.lsp.util.apply_text_edits
instead? See https://github.com/aznhe21/actions-preview.nvim/blob/9f52a01c374318e91337697ebed51c6fae57f8a4/lua/actions-preview/action.lua#L59-L66
apply_text_edits
Unfortunately, LSPs send back textChanges for some actions, which is not supported (I think, I haven't found anything about it) with native LSP in Neovim, so that's why I used custom logic. But yes, for some actions, it can work with apply_text_edits
I really can't have the same actions as yours. I do not understand why, I did install rust-analyzer (2024-07-22)
(as 2024-07-21
was not in mason) and cargo 1.80.0 (376290515 2024-07-16)
. I've tried to get code actions for every characters in the demo file, and I can't have the same as yours... Do you have some specifics configurations? It will made my life easier if I can debug a real example.
EDIT: But I use apply_workspace_edit
/execute_command
when applying the code action selected by the user onto the buffer
Do you have some specifics configurations?
I don't think so. I just use the default configuration from nvim-lspconfig.
Okay I did reproduce the issue.
You probably have rustacean
installed. I've modified the code to merge lines if needed, so you shouldn't have the issue anymore.
Original code:
Plugin diff:
Actual result:
Plugin diff:
Actual result:
actions-preview.nvim
works as expected.