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.
This commit is contained in:
Marty Oehme 2024-08-15 09:40:47 +02:00
parent ec791fda5f
commit 56951911f6
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -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 = { ["<c-t>"] = require("trouble.sources.telescope").open },
n = { ["<c-t>"] = 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 = { ["<c-t>"] = require("trouble.sources.telescope").open },
n = { ["<c-t>"] = require("trouble.sources.telescope").open },
},
mappings = trouble_mappings or {},
},
pickers = {
buffers = { theme = "ivy" },