How do I view all LSP diagnostics in a structured list with Trouble?
Answer
:Trouble diagnostics
Explanation
trouble.nvim provides a beautiful, structured view of diagnostics, quickfix entries, LSP references, and more. It replaces the default quickfix window with an interactive, auto-updating list that groups results by file and shows inline previews.
How it works
:Trouble diagnostics— show all workspace diagnostics:Trouble diagnostics filter.buf=0— show diagnostics for current buffer only:Trouble qflist— replace the quickfix window with Trouble's UI:Trouble lsp_references— show all references to the symbol under cursor
Example
nnoremap <leader>xx :Trouble diagnostics toggle<CR>
nnoremap <leader>xd :Trouble diagnostics toggle filter.buf=0<CR>
Trouble window:
▼ src/main.py (3)
● line 12: 'unused_var' is not accessed (warning)
● line 25: Expected type 'int', got 'str' (error)
● line 40: Missing return statement (error)
▼ src/utils.py (1)
● line 8: Import 'os' is unused (warning)
Tips
- Press
oto open a file at the diagnostic location - Results update automatically as you fix issues
- Use
:Trouble symbolsto browse document symbols (functions, classes) - Trouble v3 supports custom sources — you can create your own providers