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_close = true, -- auto close when there are no items
11 auto_open = true, -- auto open when there are items
12 auto_preview = true, -- automatically open preview when on an item
13 auto_refresh = true, -- auto refresh when open
14 auto_jump = false, -- auto jump to the item when there's only one
15 focus = false, -- Focus the window when opened
16 restore = true, -- restores the last location in the list when opening
17 follow = true, -- Follow the current item
18 indent_guides = true, -- show indent guides
19 max_items = 200, -- limit number of items that can be displayed per section
20 multiline = true, -- render multi-line messages
21 pinned = false, -- When pinned, the opened trouble window will be bound to the current buffer
22 warn_no_results = true, -- show a warning when there are no results
23 open_no_results = false, -- open the trouble window when there are no results
24 win = {}, -- window options for the results window. Can be a split or a floating window.
25 -- Window options for the preview window. Can be a split, floating window,
26 -- or `main` to show the preview in the main editor window.
28 -- when a buffer is not yet loaded, the preview window will be created
29 -- in a scratch buffer with only syntax highlighting enabled.
30 -- Set to false, if you want the preview to always be a real loaded buffer.
33 -- Throttle/Debounce settings. Should usually not be changed.
35 refresh = 20, -- fetches new data when needed
36 update = 10, -- updates the window
37 render = 10, -- renders the window
38 follow = 100, -- follows the current item
39 preview = { ms = 100, debounce = true }, -- shows the preview for the current item
41 -- Key mappings can be set to the name of a builtin action,
42 -- or you can define your own custom action.
51 ["<2-leftmouse>"] = "jump",
52 ["<c-s>"] = "jump_split",
53 ["<c-v>"] = "jump_vsplit",
54 -- go down to next item (accepts count)
58 -- go up to prev item (accepts count)
63 d = { action = "delete", mode = "v" },
68 zO = "fold_open_recursive",
70 zC = "fold_close_recursive",
72 zA = "fold_toggle_recursive",
74 zM = "fold_close_all",
78 zX = "fold_update_all",
81 zi = "fold_toggle_enable",
82 gb = { -- example of a custom action that toggles the active view filter
83 action = function(view)
84 view:filter({ buf = 0 }, { toggle = true })
86 desc = "Toggle Current Buffer Filter",
88 s = { -- example of a custom action that toggles the severity
89 action = function(view)
90 local f = view:get_filter("severity")
91 local severity = ((f and f.filter.severity or 0) + 1) % 5
92 view:filter({ severity = severity }, {
94 template = "{hl:Title}Filter:{hl} {severity}",
98 desc = "Toggle Severity Filter",
102 -- sources define their own modes, which you can use directly,
103 -- or override like in the example below
105 -- some modes are configurable, see the source code for more details
107 include_declaration = true,
110 -- The LSP base mode for:
111 -- * lsp_definitions, lsp_references, lsp_implementations
112 -- * lsp_type_definitions, lsp_declarations, lsp_command
115 -- don't include the current location in the results
116 include_current = false,
119 -- more advanced example that extends the lsp_document_symbols
121 desc = "document symbols",
122 mode = "lsp_document_symbols",
124 win = { position = "right" },
126 -- remove Package since luals uses it for control flow structures
127 ["not"] = { ft = "lua", kind = "Package" },
129 -- all symbol kinds for help / markdown files
130 ft = { "help", "markdown" },
131 -- default set of symbol kinds
152 vim.keymap.set("n", "<C-j>", trouble.prev, {})
153 vim.keymap.set("n", "<C-l>", trouble.next, {})
158 "<cmd>Trouble diagnostics toggle<cr>",
159 desc = "Diagnostics (Trouble)",
163 "<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
164 desc = "Buffer Diagnostics (Trouble)",
168 "<cmd>Trouble symbols toggle focus=false<cr>",
169 desc = "Symbols (Trouble)",
173 "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
174 desc = "LSP Definitions / references / ... (Trouble)",
178 "<cmd>Trouble loclist toggle<cr>",
179 desc = "Location List (Trouble)",
183 "<cmd>Trouble qflist toggle<cr>",
184 desc = "Quickfix List (Trouble)",