1 -- A pretty diagnostics, references, telescope results, quickfix and location list
2 -- to help you solve all the trouble your code is causing.
3 -- https://github.com/folke/trouble.nvim
8 local trouble = require("trouble")
10 auto_preview = true, -- automatically open preview when on an item
11 auto_refresh = true, -- auto refresh when open
12 auto_jump = false, -- auto jump to the item when there's only one
13 focus = false, -- Focus the window when opened
14 restore = true, -- restores the last location in the list when opening
15 follow = true, -- Follow the current item
16 indent_guides = true, -- show indent guides
17 max_items = 200, -- limit number of items that can be displayed per section
18 multiline = true, -- render multi-line messages
19 pinned = false, -- When pinned, the opened trouble window will be bound to the current buffer
20 warn_no_results = true, -- show a warning when there are no results
21 open_no_results = false, -- open the trouble window when there are no results
22 win = {}, -- window options for the results window. Can be a split or a floating window.
23 -- Window options for the preview window. Can be a split, floating window,
24 -- or `main` to show the preview in the main editor window.
26 -- when a buffer is not yet loaded, the preview window will be created
27 -- in a scratch buffer with only syntax highlighting enabled.
28 -- Set to false, if you want the preview to always be a real loaded buffer.
31 -- Throttle/Debounce settings. Should usually not be changed.
33 refresh = 20, -- fetches new data when needed
34 update = 10, -- updates the window
35 render = 10, -- renders the window
36 follow = 100, -- follows the current item
37 preview = { ms = 100, debounce = true }, -- shows the preview for the current item
39 -- Key mappings can be set to the name of a builtin action,
40 -- or you can define your own custom action.
49 ["<2-leftmouse>"] = "jump",
50 ["<c-s>"] = "jump_split",
51 ["<c-v>"] = "jump_vsplit",
52 -- go down to next item (accepts count)
56 -- go up to prev item (accepts count)
61 d = { action = "delete", mode = "v" },
66 zO = "fold_open_recursive",
68 zC = "fold_close_recursive",
70 zA = "fold_toggle_recursive",
72 zM = "fold_close_all",
76 zX = "fold_update_all",
79 zi = "fold_toggle_enable",
80 gb = { -- example of a custom action that toggles the active view filter
81 action = function(view)
82 view:filter({ buf = 0 }, { toggle = true })
84 desc = "Toggle Current Buffer Filter",
86 s = { -- example of a custom action that toggles the severity
87 action = function(view)
88 local f = view:get_filter("severity")
89 local severity = ((f and f.filter.severity or 0) + 1) % 5
90 view:filter({ severity = severity }, {
92 template = "{hl:Title}Filter:{hl} {severity}",
96 desc = "Toggle Severity Filter",
101 auto_close = false, -- auto close when there are no items
102 auto_open = false, -- auto open when there are items
103 auto_preview = true, -- automatically open preview when on an item
104 auto_refresh = true, -- auto refresh when open
106 -- sources define their own modes, which you can use directly,
107 -- or override like in the example below
109 -- some modes are configurable, see the source code for more details
111 include_declaration = true,
114 -- The LSP base mode for:
115 -- * lsp_definitions, lsp_references, lsp_implementations
116 -- * lsp_type_definitions, lsp_declarations, lsp_command
119 -- don't include the current location in the results
120 include_current = false,
123 -- more advanced example that extends the lsp_document_symbols
125 desc = "document symbols",
126 mode = "lsp_document_symbols",
128 win = { position = "right" },
130 -- remove Package since luals uses it for control flow structures
131 ["not"] = { ft = "lua", kind = "Package" },
133 -- all symbol kinds for help / markdown files
134 ft = { "help", "markdown" },
135 -- default set of symbol kinds
156 vim.keymap.set("n", "<C-j>", trouble.prev, {})
157 vim.keymap.set("n", "<C-l>", trouble.next, {})
162 "<cmd>Trouble diagnostics toggle<cr>",
163 desc = "Diagnostics (Trouble)",
167 "<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
168 desc = "Buffer Diagnostics (Trouble)",
172 "<cmd>Trouble symbols toggle focus=false<cr>",
173 desc = "Symbols (Trouble)",
177 "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
178 desc = "LSP Definitions / references / ... (Trouble)",
182 "<cmd>Trouble loclist toggle<cr>",
183 desc = "Location List (Trouble)",
187 "<cmd>Trouble qflist toggle<cr>",
188 desc = "Quickfix List (Trouble)",