folke / trouble.nvim

🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Apache License 2.0
5.44k stars 177 forks source link

feature: Editing the text in the trouble window to sync back to the original position #443

Closed IndianBoy42 closed 4 months ago

IndianBoy42 commented 4 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

This is a workflow I really like from using replacer.nvim where the quickfix list is turned into a buffer that I can edit and when I save the lines in the original buffers/files are edited. This is really powerful because you can then seamlessly use all the editing tricks and workflows you have in a normal buffer

Describe the solution you'd like

This probably shouldn't be too easy to activate, like needing <C-e> to make the buffer editable, at which point preview and some other features are turned off and the user can start editing the buffer as normal. On BufWritePost or perhaps a separate keybinding these edits are synced back to the buffers. Of course this is only relevant for certain lists that actually have such a mapping to certain positions in files. For diagnostics maybe editable mode should add in the line that the diagnostic is pointing to so it can be edited.

Describe alternatives you've considered

Currently trouble is just a navigation plugin so we have to jump between each position and do whatever actions and edits we want.

Additional context

No response

folke commented 4 months ago

This is not really something that would be easy to implement. What you see in trouble, are rendered templates that can be basically anything, so it's almost impossible to correctly link that back to the original file.

What you can do instead, is use vertical splits for the preview (see examples) and set opts.preview.scratch = false. That way, you can make edits in the preview window.

Not the same, I know, but the closest you can get to what you want.