Skip to content

Commit 1fdec71

Browse files
Refine plugin configurations for Trouble and Lazy UI
Updates `trouble.nvim` settings, including a more detailed icon configuration. Comments out `which-key` registration for `trouble` and `goto` commands. Adds a 'git' icon to the `lazy.nvim` interface. Localizes `vim` global in `init.lua`.
1 parent b94576c commit 1fdec71

File tree

2 files changed

+68
-60
lines changed

2 files changed

+68
-60
lines changed

init.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ I hope you enjoy your Neovim journey,
8383
8484
P.S. You can delete this when you're done too. It's your config now! :)
8585
--]]
86-
86+
--
87+
local vim = vim
8788
-- Set <space> as the leader key
8889
-- See `:help mapleader`
8990
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
@@ -1030,6 +1031,7 @@ require('lazy').setup({
10301031
start = '🚀',
10311032
task = '📌',
10321033
lazy = '💤 ',
1034+
git = 'g',
10331035
},
10341036
},
10351037
})

lua/custom/plugins/trouble.lua

Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,86 +2,92 @@
22
-- https://github.com/folke/trouble.nvim
33

44
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' },
99
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
1111
height = 12, -- height of the trouble list when position is top or bottom
1212
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"
1526
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
1827
group = true, -- group results by file
1928
padding = true, -- add an extra new line on top of the list
2029
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
4150
},
4251
multiline = true, -- render multi-line messages
4352
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
4554
auto_open = false, -- automatically open the list when you have diagnostics
4655
auto_close = false, -- automatically close the list when you have no diagnostics
4756
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
4857
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
5059
signs = {
5160
-- 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 = '',
5766
},
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
5968
},
6069
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)' },
6877
},
6978
config = function(_, opts)
70-
require("trouble").setup(opts)
71-
79+
require('trouble').setup(opts)
7280
-- 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
8692
end,
8793
}

0 commit comments

Comments
 (0)