]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/nvim/lua/plugins/trouble.lua
Usability/Operability(neovim): enable trouble.nvim
[julm/julm-nix.git] / home-manager / profiles / nvim / lua / plugins / trouble.lua
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
4 return {
5 "trouble.nvim",
6 cmd = { "Trouble" },
7 after = function()
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.
26 preview = {
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.
30 scratch = true,
31 },
32 -- Throttle/Debounce settings. Should usually not be changed.
33 throttle = {
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
39 },
40 -- Key mappings can be set to the name of a builtin action,
41 -- or you can define your own custom action.
42 keys = {
43 ["?"] = "help",
44 r = "refresh",
45 R = "toggle_refresh",
46 q = "close",
47 o = "jump_close",
48 ["<esc>"] = "cancel",
49 ["<cr>"] = "jump",
50 ["<2-leftmouse>"] = "jump",
51 ["<c-s>"] = "jump_split",
52 ["<c-v>"] = "jump_vsplit",
53 -- go down to next item (accepts count)
54 -- j = "next",
55 ["}"] = "next",
56 ["]]"] = "next",
57 -- go up to prev item (accepts count)
58 -- k = "prev",
59 ["{"] = "prev",
60 ["[["] = "prev",
61 dd = "delete",
62 d = { action = "delete", mode = "v" },
63 i = "inspect",
64 p = "preview",
65 P = "toggle_preview",
66 zo = "fold_open",
67 zO = "fold_open_recursive",
68 zc = "fold_close",
69 zC = "fold_close_recursive",
70 za = "fold_toggle",
71 zA = "fold_toggle_recursive",
72 zm = "fold_more",
73 zM = "fold_close_all",
74 zr = "fold_reduce",
75 zR = "fold_open_all",
76 zx = "fold_update",
77 zX = "fold_update_all",
78 zn = "fold_disable",
79 zN = "fold_enable",
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 })
84 end,
85 desc = "Toggle Current Buffer Filter",
86 },
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 }, {
92 id = "severity",
93 template = "{hl:Title}Filter:{hl} {severity}",
94 del = severity == 0,
95 })
96 end,
97 desc = "Toggle Severity Filter",
98 },
99 },
100 modes = {
101 -- sources define their own modes, which you can use directly,
102 -- or override like in the example below
103 lsp_references = {
104 -- some modes are configurable, see the source code for more details
105 params = {
106 include_declaration = true,
107 },
108 },
109 -- The LSP base mode for:
110 -- * lsp_definitions, lsp_references, lsp_implementations
111 -- * lsp_type_definitions, lsp_declarations, lsp_command
112 lsp_base = {
113 params = {
114 -- don't include the current location in the results
115 include_current = false,
116 },
117 },
118 -- more advanced example that extends the lsp_document_symbols
119 symbols = {
120 desc = "document symbols",
121 mode = "lsp_document_symbols",
122 focus = false,
123 win = { position = "right" },
124 filter = {
125 -- remove Package since luals uses it for control flow structures
126 ["not"] = { ft = "lua", kind = "Package" },
127 any = {
128 -- all symbol kinds for help / markdown files
129 ft = { "help", "markdown" },
130 -- default set of symbol kinds
131 kind = {
132 "Class",
133 "Constructor",
134 "Enum",
135 "Field",
136 "Function",
137 "Interface",
138 "Method",
139 "Module",
140 "Namespace",
141 "Package",
142 "Property",
143 "Struct",
144 "Trait",
145 },
146 },
147 },
148 },
149 },
150 })
151 end,
152 keys = {
153 {
154 "<leader>xx",
155 "<cmd>Trouble diagnostics toggle<cr>",
156 desc = "Diagnostics (Trouble)",
157 },
158 {
159 "<leader>xX",
160 "<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
161 desc = "Buffer Diagnostics (Trouble)",
162 },
163 {
164 "<leader>cs",
165 "<cmd>Trouble symbols toggle focus=false<cr>",
166 desc = "Symbols (Trouble)",
167 },
168 {
169 "<leader>cl",
170 "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
171 desc = "LSP Definitions / references / ... (Trouble)",
172 },
173 {
174 "<leader>xL",
175 "<cmd>Trouble loclist toggle<cr>",
176 desc = "Location List (Trouble)",
177 },
178 {
179 "<leader>xQ",
180 "<cmd>Trouble qflist toggle<cr>",
181 desc = "Quickfix List (Trouble)",
182 },
183 },
184 }