diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 0000000..fe73a96 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,10 @@ +return { + { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + config = function() + require "custom/trouble" + end, + }, +} diff --git a/lua/custom/trouble.lua b/lua/custom/trouble.lua new file mode 100644 index 0000000..019be4f --- /dev/null +++ b/lua/custom/trouble.lua @@ -0,0 +1,28 @@ +local trouble = require("trouble") + +-- Setup Trouble +trouble.setup() + +-- Keybindings +vim.keymap.set("n", "xx", "Trouble diagnostics toggle", { desc = "Diagnostics (Trouble)" }) +vim.keymap.set("n", "xX", "Trouble diagnostics toggle filter.buf=0", + { desc = "Buffer Diagnostics (Trouble)" }) +vim.keymap.set("n", "cs", "Trouble symbols toggle focus=false", { desc = "Symbols (Trouble)" }) +vim.keymap.set("n", "cl", "Trouble lsp toggle focus=false win.position=right", + { desc = "LSP Definitions / references / ... (Trouble)" }) +vim.keymap.set("n", "xL", "Trouble loclist toggle", { desc = "Location List (Trouble)" }) +vim.keymap.set("n", "xQ", "Trouble qflist toggle", { desc = "Quickfix List (Trouble)" }) + +-- Telescope integration +local actions = require("telescope.actions") +local open_with_trouble = require("trouble.sources.telescope").open +local add_to_trouble = require("trouble.sources.telescope").add + +require("telescope").setup({ + defaults = { + mappings = { + i = { [""] = open_with_trouble }, + n = { [""] = open_with_trouble }, + }, + }, +})