trouble.nvim
trouble.nvim copied to clipboard
Focus current line when opening Trouble
If my cursor is on a line with an error when I open Trouble, I'd like trouble to show the errors on that line.
Prerequisite:
Have your cursor on a line that has an error on it. Then run :Trouble
Current behaviour: Trouble will open, and select the first error in the workspace. Your cursor will jump away from its current position to the file/location of the first error listed in Trouble.
Desired behaviour: Trouble should recognize that there is an error on the current line, and initially focus that error. If not too difficult, it would be nice if it found the nearest error to the cursor, so if you were next to an error but not on it, Trouble would still jump to that error. But that's not quite as important to me.
totally makes sense. I'll add it at some point.
This is also annoying when using require("trouble").next(...)
and require("trouble").previous(...)
without having Trouble focused. Once I switch focus back to Trouble, I'm at the first item again. Would you accept PRs for this?
@tom-anders yes! Sorry, didn't have the time yet to work on this myself. A PR would be much appreciated.
Cool, I'll see if I find some time to work on this over the weekend.
Btw, the use case I described in my comment above actually already works, looks like it was just a problem with my configuration. However, I think it would be cool to have the current line highlighted in Trouble in that case, even when Trouble is not focused (just like the quickfix window does). Know what I mean?
Any news on this? At least setting auto_preview = false
prevents the jumping around.
It would be nice to extend this to lsp_references
and other actions too.
So for example when you open Trouble references
in the Trouble window the current reference would be nice to be selected instead of the first one.
This PR I opened should probably help with this issue.
Probably it needs some adjustments (it's been more than a year since I opened it)
I'm definitely down with this to match the ALE style. I'm really surprised more people don't like this, and would rather have a popup window
Development on the main branch is EOL.
Trouble has been rewritten and will be merged in main soon.
This issue/feature either no longer exists or has been implemented on dev.
For more info, see https://github.com/folke/trouble.nvim/tree/dev