From 3460ac56508c59c9a366a451d0e10aa42c2039a3 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Wed, 1 Jan 2025 17:44:00 -0800 Subject: [PATCH] feat: trouble.nvim --- nix/neovim-overlay.nix | 1 + nvim/lua/plugins/editor/init.lua | 1 + nvim/lua/plugins/editor/trouble-nvim.lua | 55 ++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 nvim/lua/plugins/editor/trouble-nvim.lua diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 4484d1c..a685ec0 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -52,6 +52,7 @@ with final.pkgs.lib; let flash-nvim which-key-nvim gitsigns-nvim + trouble-nvim aerial-nvim # Treesitter diff --git a/nvim/lua/plugins/editor/init.lua b/nvim/lua/plugins/editor/init.lua index 779d5b9..8323854 100644 --- a/nvim/lua/plugins/editor/init.lua +++ b/nvim/lua/plugins/editor/init.lua @@ -6,5 +6,6 @@ return { req('gitsigns-nvim'), req('grug-far-nvim'), req('neo-tree-nvim'), + req('trouble-nvim'), req('which-key-nvim'), } diff --git a/nvim/lua/plugins/editor/trouble-nvim.lua b/nvim/lua/plugins/editor/trouble-nvim.lua new file mode 100644 index 0000000..b5f7b7a --- /dev/null +++ b/nvim/lua/plugins/editor/trouble-nvim.lua @@ -0,0 +1,55 @@ +return { + 'trouble.nvim', + cmd = { 'Trouble' }, + keys = { + { + 'xQ', + 'Trouble qflist toggle', + desc = 'quickfix list (trouble)', + }, + { + 'xx', + 'Trouble diagnostics toggle', + desc = 'diagnostics', + }, + { + 'xX', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'buffer diagnostics', + }, + { + '[q', + function() + if require('trouble').is_open() then + require('trouble').prev({ skip_groups = true, jump = true }) + else + local ok, err = pcall(vim.cmd.cprev) + + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + desc = 'previous trouble/quickfix item', + }, + { + ']q', + function() + if require('trouble').is_open() then + require('trouble').next({ skip_groups = true, jump = true }) + else + local ok, err = pcall(vim.cmd.cnext) + + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + }, + }, + after = function() + require('trouble').setup({ + modes = { lsp = { win = { position = 'right' } } }, + }) + end, +}