trouble.nvim icon indicating copy to clipboard operation
trouble.nvim copied to clipboard

Way to apply code actions from within trouble

Open cameron1024 opened this issue 3 years ago • 2 comments
trafficstars

First of all, really enjoying this plugin, nice work!

One thing I'm missing from VSCode is the ability to apply a code action/quickfix from the "problems" tab: image

The specific use case that I have in mind is something like: I change the signature of a function slightly (e.g. in Rust, changing a parameter from a Foo to an &Foo for example, which is trivially fixable by the language server). This breaks every call of that function, so I'd like to be able to go through the trouble list of workspace diagnostics and quickly apply the fix. Currently, I have to press enter to go to that location in a buffer, then apply the fix.

I'm not sure if this is possible in trouble already, but if not, does this sound like something that could be feasibly added? If so, maybe a "fix all" option as well could be nice. FWIW, I'm not a NeoVim expert, so if there's a way to do this already using builtin stuff I'd be happy to use that :)

cameron1024 avatar Jan 30 '22 22:01 cameron1024

It will be pretty a heavy job to make codeactions included in trouble.nvim. Some known alternatives are https://github.com/ray-x/navigator.lua, https://github.com/weilbith/nvim-code-action-menu, or Telescope.

wookayin avatar Feb 02 '22 02:02 wookayin

for this you would use the buitin loclist (the list of errors referred to the local buffer that trouble substitutes) and commands like :ldo stuff that is loclist do to move thought the entries in the loclist and run a series of commands. I found this issue because I am looking for a way to make loclist (used by errors) and quickfix (used by references) behave closer to how trouble does to maintain the advantages of a normal loclist for cases such the one you described

DavidePatria avatar Apr 05 '22 13:04 DavidePatria