trouble.nvim
trouble.nvim copied to clipboard
Severity Filtering and Cascading Severity
Sometimes working on a big code change, your LSP starts shouting at you. Many of these are often warnings, many more are hints. Often a single error in code will have an error AND a hint attached. I found this got in the way; I love rustc, but hints are best for printed diagnostics and inline suggestions, not a summary of the workspace when you have more important things to do.
I've implemented two things here:
- A severity filter, default keys
+
and-
to change the minimum severity of diagnostics displayed in the trouble window. - A cascading severity filter, which will e.g. show errors only until there are no errors, then warnings only until there are no warnings, then info only ... keys
(
and)
will change at what level this flattens out to show you all remaining diagnostics. So you can have "errors until there are no errors, everything else after that".
I made a little video illustrating these features. (Yes, I originally made this a few months ago. Slipped my mind to PR!)
https://user-images.githubusercontent.com/378760/132983006-6b0255c8-c85f-4157-9fdd-326d4e6d0d87.mov
I hope to see this merged; it would also go a long way to helping with #35 — at least in my use-case, where there's a giant flood of one specific 'hint', and i don't care at all about any of the other 'hints.'

Edit: Oh, yeah, this is fantastic.

Hello @folke, Has your stance changed since https://github.com/folke/trouble.nvim/issues/35#issuecomment-844943749 ? I too would like this feature, but if you don't feel that it is in the scope of the plugin, that's understandable (maybe then this could be closed to manage expectations).
Thanks !
I don't think that comment from @folke had much to do with this at all, it was about filtering on the diagnostic content to correct an LSP giving unwanted errors. This is only about filtering on severity, a field that only exists in order to facilitate things like this PR.
In other news Neovim 0.6 has been released and it has some features for sorting diagnostics, haven't looked into this in any depth but obviously could be relevant, or not.
https://github.com/neovim/neovim/commit/32c0631183a64925d38a13819db9557f8da02738
Yes I'm not sure either that's why I'm seeking more information so that I can decide on what to do in my config :)
Thank you for this PR.
Any hopes of getting this merged, or are there other ways of filtering based on severity?
@folke I've rebased this onto latest main if you want to have a look.
Closing this in favor of https://github.com/folke/trouble.nvim/pull/285
Thanks @cormacrelf, I hope you keep your fork around for those of us who want the cascading severity - I'm using:
Plug 'cormacrelf/trouble.nvim', { 'branch': 'cascading-sev-2' }
@folke can you explain your reasoning for rejecting this in favour of #285? That way we can understand how we might submit PRs for the remaining functionality. Was the problem just that the README wasn't updated?