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