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 require("trouble").setup({
9 auto_close = false, -- auto close when there are no items
10 auto_open = false, -- auto open when there are items
11 auto_preview = true, -- automatically open preview when on an item
12 auto_refresh = true, -- auto refresh when open
13 auto_jump = false, -- auto jump to the item when there's only one
14 focus = false, -- Focus the window when opened
15 restore = true, -- restores the last location in the list when opening
16 follow = true, -- Follow the current item
17 indent_guides = true, -- show indent guides
18 max_items = 200, -- limit number of items that can be displayed per section
19 multiline = true, -- render multi-line messages
20 pinned = false, -- When pinned, the opened trouble window will be bound to the current buffer
21 warn_no_results = true, -- show a warning when there are no results
22 open_no_results = false, -- open the trouble window when there are no results
23 win = {}, -- window options for the results window. Can be a split or a floating window.
24 -- Window options for the preview window. Can be a split, floating window,
25 -- or `main` to show the preview in the main editor window.
27 -- when a buffer is not yet loaded, the preview window will be created
28 -- in a scratch buffer with only syntax highlighting enabled.
29 -- Set to false, if you want the preview to always be a real loaded buffer.
32 -- Throttle/Debounce settings. Should usually not be changed.
34 refresh = 20, -- fetches new data when needed
35 update = 10, -- updates the window
36 render = 10, -- renders the window
37 follow = 100, -- follows the current item
38 preview = { ms = 100, debounce = true }, -- shows the preview for the current item
40 -- Key mappings can be set to the name of a builtin action,
41 -- or you can define your own custom action.
50 ["<2-leftmouse>"] = "jump",
51 ["<c-s>"] = "jump_split",
52 ["<c-v>"] = "jump_vsplit",
53 -- go down to next item (accepts count)
57 -- go up to prev item (accepts count)
62 d = { action = "delete", mode = "v" },
67 zO = "fold_open_recursive",
69 zC = "fold_close_recursive",
71 zA = "fold_toggle_recursive",
73 zM = "fold_close_all",
77 zX = "fold_update_all",
80 zi = "fold_toggle_enable",
81 gb = { -- example of a custom action that toggles the active view filter
82 action = function(view)
83 view:filter({ buf = 0 }, { toggle = true })
85 desc = "Toggle Current Buffer Filter",
87 s = { -- example of a custom action that toggles the severity
88 action = function(view)
89 local f = view:get_filter("severity")
90 local severity = ((f and f.filter.severity or 0) + 1) % 5
91 view:filter({ severity = severity }, {
93 template = "{hl:Title}Filter:{hl} {severity}",
97 desc = "Toggle Severity Filter",
101 -- sources define their own modes, which you can use directly,
102 -- or override like in the example below
104 -- some modes are configurable, see the source code for more details
106 include_declaration = true,
109 -- The LSP base mode for:
110 -- * lsp_definitions, lsp_references, lsp_implementations
111 -- * lsp_type_definitions, lsp_declarations, lsp_command
114 -- don't include the current location in the results
115 include_current = false,
118 -- more advanced example that extends the lsp_document_symbols
120 desc = "document symbols",
121 mode = "lsp_document_symbols",
123 win = { position = "right" },
125 -- remove Package since luals uses it for control flow structures
126 ["not"] = { ft = "lua", kind = "Package" },
128 -- all symbol kinds for help / markdown files
129 ft = { "help", "markdown" },
130 -- default set of symbol kinds
155 "<cmd>Trouble diagnostics toggle<cr>",
156 desc = "Diagnostics (Trouble)",
160 "<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
161 desc = "Buffer Diagnostics (Trouble)",
165 "<cmd>Trouble symbols toggle focus=false<cr>",
166 desc = "Symbols (Trouble)",
170 "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
171 desc = "LSP Definitions / references / ... (Trouble)",
175 "<cmd>Trouble loclist toggle<cr>",
176 desc = "Location List (Trouble)",
180 "<cmd>Trouble qflist toggle<cr>",
181 desc = "Quickfix List (Trouble)",