|
2 | 2 | -- https://github.com/folke/trouble.nvim |
3 | 3 |
|
4 | 4 | return { |
5 | | - "folke/trouble.nvim", |
6 | | - dependencies = { "nvim-tree/nvim-web-devicons" }, |
7 | | - event = { "BufReadPost", "BufNewFile" }, |
8 | | - cmd = { "TroubleToggle", "Trouble" }, |
| 5 | + 'folke/trouble.nvim', |
| 6 | + dependencies = { 'nvim-tree/nvim-web-devicons' }, |
| 7 | + event = { 'BufReadPost', 'BufNewFile' }, |
| 8 | + cmd = { 'TroubleToggle', 'Trouble' }, |
9 | 9 | opts = { |
10 | | - position = "bottom", -- position of the list can be: bottom, top, left, right |
| 10 | + position = 'bottom', -- position of the list can be: bottom, top, left, right |
11 | 11 | height = 12, -- height of the trouble list when position is top or bottom |
12 | 12 | width = 50, -- width of the list when position is left or right |
13 | | - icons = true, -- use devicons for filenames |
14 | | - mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" |
| 13 | + icons = { |
| 14 | + indent = { |
| 15 | + top = "│ ", |
| 16 | + middle = "├╴", |
| 17 | + last = "└╴", |
| 18 | + fold_open = " ", |
| 19 | + fold_closed = " ", |
| 20 | + ws = " ", |
| 21 | + }, |
| 22 | + folder_closed = " ", |
| 23 | + folder_open = " ", |
| 24 | + }, |
| 25 | + mode = 'workspace_diagnostics', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" |
15 | 26 | severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT |
16 | | - fold_open = "", -- icon used for open folds |
17 | | - fold_closed = "", -- icon used for closed folds |
18 | 27 | group = true, -- group results by file |
19 | 28 | padding = true, -- add an extra new line on top of the list |
20 | 29 | action_keys = { -- key mappings for actions in the trouble list |
21 | | - close = "q", -- close the list |
22 | | - cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor |
23 | | - refresh = "r", -- manually refresh |
24 | | - jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds |
25 | | - open_split = { "<c-x>" }, -- open buffer in new split |
26 | | - open_vsplit = { "<c-v>" }, -- open buffer in new vsplit |
27 | | - open_tab = { "<c-t>" }, -- open buffer in new tab |
28 | | - jump_close = {"o"}, -- jump to the diagnostic and close the list |
29 | | - toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode |
30 | | - switch_severity = "s", -- switch "diagnostics" severity filter |
31 | | - toggle_preview = "P", -- toggle auto_preview |
32 | | - hover = "K", -- opens a small popup with the full multiline message |
33 | | - preview = "p", -- preview the diagnostic location |
34 | | - open_code_href = "c", -- if present, open a URI with more information about the diagnostic error |
35 | | - close_folds = {"zM", "zm"}, -- close all folds |
36 | | - open_folds = {"zR", "zr"}, -- open all folds |
37 | | - toggle_fold = {"zA", "za"}, -- toggle fold of current file |
38 | | - previous = "k", -- previous item |
39 | | - next = "j", -- next item |
40 | | - help = "?" -- help menu |
| 30 | + close = 'q', -- close the list |
| 31 | + cancel = '<esc>', -- cancel the preview and get back to your last window / buffer / cursor |
| 32 | + refresh = 'r', -- manually refresh |
| 33 | + jump = { '<cr>', '<tab>', '<2-leftmouse>' }, -- jump to the diagnostic or open / close folds |
| 34 | + open_split = { '<c-x>' }, -- open buffer in new split |
| 35 | + open_vsplit = { '<c-v>' }, -- open buffer in new vsplit |
| 36 | + open_tab = { '<c-t>' }, -- open buffer in new tab |
| 37 | + jump_close = { 'o' }, -- jump to the diagnostic and close the list |
| 38 | + toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode |
| 39 | + switch_severity = 's', -- switch "diagnostics" severity filter |
| 40 | + toggle_preview = 'P', -- toggle auto_preview |
| 41 | + hover = 'K', -- opens a small popup with the full multiline message |
| 42 | + preview = 'p', -- preview the diagnostic location |
| 43 | + open_code_href = 'c', -- if present, open a URI with more information about the diagnostic error |
| 44 | + close_folds = { 'zM', 'zm' }, -- close all folds |
| 45 | + open_folds = { 'zR', 'zr' }, -- open all folds |
| 46 | + toggle_fold = { 'zA', 'za' }, -- toggle fold of current file |
| 47 | + previous = 'k', -- previous item |
| 48 | + next = 'j', -- next item |
| 49 | + help = '?', -- help menu |
41 | 50 | }, |
42 | 51 | multiline = true, -- render multi-line messages |
43 | 52 | indent_lines = true, -- add an indent guide below the fold icons |
44 | | - win_config = { border = "rounded" }, -- window configuration for floating windows |
| 53 | + win_config = { border = 'rounded' }, -- window configuration for floating windows |
45 | 54 | auto_open = false, -- automatically open the list when you have diagnostics |
46 | 55 | auto_close = false, -- automatically close the list when you have no diagnostics |
47 | 56 | auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window |
48 | 57 | auto_fold = false, -- automatically fold a file trouble list at creation |
49 | | - auto_jump = {"lsp_definitions"}, -- for the given modes, automatically jump if there is only a single result |
| 58 | + auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result |
50 | 59 | signs = { |
51 | 60 | -- icons / text used for a diagnostic |
52 | | - error = "", |
53 | | - warning = "", |
54 | | - hint = "", |
55 | | - information = "", |
56 | | - other = "", |
| 61 | + error = '', |
| 62 | + warning = '', |
| 63 | + hint = '', |
| 64 | + information = '', |
| 65 | + other = '', |
57 | 66 | }, |
58 | | - use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client |
| 67 | + use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client |
59 | 68 | }, |
60 | 69 | keys = { |
61 | | - { "<leader>xx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" }, |
62 | | - { "<leader>xX", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" }, |
63 | | - { "<leader>xL", "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" }, |
64 | | - { "<leader>xQ", "<cmd>TroubleToggle quickfix<cr>", desc = "Quickfix List (Trouble)" }, |
65 | | - { "gR", "<cmd>TroubleToggle lsp_references<cr>", desc = "LSP References (Trouble)" }, |
66 | | - { "gD", "<cmd>TroubleToggle lsp_definitions<cr>", desc = "LSP Definitions (Trouble)" }, |
67 | | - { "<leader>xT", "<cmd>TodoTrouble<cr>", desc = "TODOs (Trouble)", cond = function() return require("lazy.core.config").spec.plugins["todo-comments"] ~= nil end }, |
| 70 | + { '<leader>xx', '<cmd>TroubleToggle document_diagnostics<cr>', desc = 'Document Diagnostics (Trouble)' }, |
| 71 | + { '<leader>xX', '<cmd>TroubleToggle workspace_diagnostics<cr>', desc = 'Workspace Diagnostics (Trouble)' }, |
| 72 | + { '<leader>xL', '<cmd>TroubleToggle loclist<cr>', desc = 'Location List (Trouble)' }, |
| 73 | + { '<leader>xQ', '<cmd>TroubleToggle quickfix<cr>', desc = 'Quickfix List (Trouble)' }, |
| 74 | + { 'gR', '<cmd>TroubleToggle lsp_references<cr>', desc = 'LSP References (Trouble)' }, |
| 75 | + { 'gD', '<cmd>TroubleToggle lsp_definitions<cr>', desc = 'LSP Definitions (Trouble)' }, |
| 76 | + { '<leader>xT', '<cmd>TodoTrouble<cr>', desc = 'TODOs (Trouble)' }, |
68 | 77 | }, |
69 | 78 | config = function(_, opts) |
70 | | - require("trouble").setup(opts) |
71 | | - |
| 79 | + require('trouble').setup(opts) |
72 | 80 | -- Add which-key group |
73 | | - local ok, which_key = pcall(require, "which-key") |
74 | | - if ok then |
75 | | - which_key.register({ |
76 | | - ["<leader>x"] = { |
77 | | - name = "Trouble/Diagnostics", |
78 | | - x = { "<cmd>TroubleToggle document_diagnostics<cr>", "Document Diagnostics" }, |
79 | | - X = { "<cmd>TroubleToggle workspace_diagnostics<cr>", "Workspace Diagnostics" }, |
80 | | - L = { "<cmd>TroubleToggle loclist<cr>", "Location List" }, |
81 | | - Q = { "<cmd>TroubleToggle quickfix<cr>", "Quickfix List" }, |
82 | | - T = { "<cmd>TodoTrouble<cr>", "TODOs" }, |
83 | | - }, |
84 | | - }) |
85 | | - end |
| 81 | + -- local ok, which_key = pcall(require, 'which-key') |
| 82 | + -- if ok then |
| 83 | + -- -- Use standard which-key format that's known to work |
| 84 | + -- which_key.register({ |
| 85 | + -- ["<leader>x"] = { name = "Trouble/Diagnostics" }, |
| 86 | + -- }) |
| 87 | + |
| 88 | + -- which_key.register({ |
| 89 | + -- ["g"] = { name = "Goto" }, |
| 90 | + -- }) |
| 91 | + -- end |
86 | 92 | end, |
87 | 93 | } |
0 commit comments