diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-09-24 00:14:04 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-09-24 00:14:04 +0200 |
| commit | 966d12ac730c83da90d60ab24eae539b2ea69441 (patch) | |
| tree | 702f5f832796b572d0faee31c0eb15507e91f49a /lua/plugins/trouble.lua | |
| parent | 2a8020a2e9b7ef2ee77ddee14892127a4eb95187 (diff) | |
| download | dotfiles-966d12ac730c83da90d60ab24eae539b2ea69441.tar.gz dotfiles-966d12ac730c83da90d60ab24eae539b2ea69441.zip | |
Update/Overhaul
Diffstat (limited to 'lua/plugins/trouble.lua')
| -rwxr-xr-x[-rw-r--r--] | lua/plugins/trouble.lua | 114 |
1 files changed, 70 insertions, 44 deletions
diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index 7d74730..4a07e3b 100644..100755 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -1,47 +1,73 @@ -require('trouble').setup({ - position = 'bottom', -- position of the list can be: bottom, top, left, right - height = 10, -- height of the trouble list when position is top or bottom - width = 50, -- width of the list when position is left or right - icons = true, -- use devicons for filenames - mode = 'document_diagnostics', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" - fold_open = '', -- icon used for open folds - fold_closed = '', -- icon used for closed folds - group = true, -- group results by file - padding = true, -- add an extra new line on top of the list - action_keys = { -- key mappings for actions in the trouble list - -- map to {} to remove a mapping, for example: - -- close = {}, - close = 'q', -- close the list - cancel = '<esc>', -- cancel the preview and get back to your last window / buffer / cursor - refresh = 'r', -- manually refresh - jump = { '<cr>', '<tab>' }, -- jump to the diagnostic or open / close folds - open_split = { '<c-x>' }, -- open buffer in new split - open_vsplit = { '<c-v>' }, -- open buffer in new vsplit - open_tab = { '<c-t>' }, -- open buffer in new tab - jump_close = { 'o' }, -- jump to the diagnostic and close the list - toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode - toggle_preview = 'P', -- toggle auto_preview - hover = 'K', -- opens a small popup with the full multiline message - preview = 'p', -- preview the diagnostic location - close_folds = { 'zM', 'zm' }, -- close all folds - open_folds = { 'zR', 'zr' }, -- open all folds - toggle_fold = { 'zA', 'za' }, -- toggle fold of current file - previous = 'k', -- previous item - next = 'j', -- next item +local M = {} + +--- Setup and configure trouble.nvim +-- This function initializes and configures the trouble plugin for diagnostics and references +-- @return boolean True if setup was successful, false otherwise +function M.setup() + local ok, trouble = pcall(require, 'trouble') + if not ok then + return false + end + + trouble.setup({ + position = "bottom", -- bottom, top, left, right + height = 10, + width = 50, + icons = { + indent = { + fold = { + open = "", + closed = "", + }, + }, + kinds = { + -- you can use LSP kind symbols or devicons here + -- remove if you want default + }, }, - indent_lines = true, -- add an indent guide below the fold icons - auto_open = false, -- automatically open the list when you have diagnostics - auto_close = false, -- automatically close the list when you have no diagnostics - auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window - auto_fold = false, -- automatically fold a file trouble list at creation - auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result + modes = { + diagnostics = { + groups = { "filename", "kind" }, + }, + symbols = { + format = "{kind_icon} {symbol.name} {symbol.kind} [{symbol.scope}]", + }, + }, + action_keys = { + close = "q", + cancel = "<esc>", + refresh = "r", + jump = { "<cr>", "<tab>" }, + open_split = { "<c-x>" }, + open_vsplit = { "<c-v>" }, + open_tab = { "<c-t>" }, + jump_close = { "o" }, + toggle_preview = "P", + hover = "K", + preview = "p", + close_folds = { "zM", "zm" }, + open_folds = { "zR", "zr" }, + toggle_fold = { "zA", "za" }, + previous = "k", + next = "j", + }, + indent_lines = true, + auto_open = false, + auto_close = false, + auto_preview = true, + auto_fold = false, + auto_jump = { "lsp_definitions" }, signs = { - -- icons / text used for a diagnostic - error = '', - warning = '▲', - information = '', - hint = '⚑', - other = '', + error = "", + warning = "▲", + info = "", + hint = "⚑", + other = "•", }, - use_diagnostic_signs = true, -- enabling this will use the signs defined in your lsp client -}) + use_diagnostic_signs = true, + }) + + return true +end + +return M |
