From 56951911f6664cd96d731977c3347916529a2983 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 15 Aug 2024 09:40:47 +0200 Subject: [PATCH] nvim: Check trouble before adding telescope maps Check that the trouble plugin exists before adding its maps to the telescope buffer. Should probably go into trouble setup instead but works as a quick safeguard for now. --- nvim/.config/nvim/lua/plugins/pickers.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/pickers.lua b/nvim/.config/nvim/lua/plugins/pickers.lua index d219df4..341a130 100644 --- a/nvim/.config/nvim/lua/plugins/pickers.lua +++ b/nvim/.config/nvim/lua/plugins/pickers.lua @@ -43,6 +43,13 @@ return { -- rg (ripgrep) for in-text searches -- fd for quicker directory structure searches -- lsp for a variety of lsp queries + local trouble_mappings = {} + if require("core.util").is_available("trouble") then + trouble_mappings = { + i = { [""] = require("trouble.sources.telescope").open }, + n = { [""] = require("trouble.sources.telescope").open }, + } + end require("telescope").setup({ defaults = { vimgrep_arguments = { @@ -61,11 +68,7 @@ return { prompt_prefix = "󰍉 ", selection_caret = "󰳟 ", color_devicons = true, - mappings = { - -- FIXME: Find way to only invoke this *IF* trouble plugin is found - i = { [""] = require("trouble.sources.telescope").open }, - n = { [""] = require("trouble.sources.telescope").open }, - }, + mappings = trouble_mappings or {}, }, pickers = { buffers = { theme = "ivy" },