From d49cf6e3ad7d4a648f1befd9df57e03de0d01fca Mon Sep 17 00:00:00 2001 From: MFlossmann Date: Sat, 13 Jul 2024 08:37:13 +0200 Subject: [PATCH] fix telescope --- plugins/telescope.nix | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/plugins/telescope.nix b/plugins/telescope.nix index 5cfeb09..0e261fb 100644 --- a/plugins/telescope.nix +++ b/plugins/telescope.nix @@ -35,27 +35,28 @@ # │ │ Preview │ │ # │ └────────────────────────────────────────┘ │ # └──────────────────────────────────────────────────┘ - # extraConfigLuaPre = '' - # local TelescopeWithTheme = function(fn, args, extension) - # args.layout_config = { - # anchor = "N", - # mirror = true, - # width = 0.8, - # } - # - # if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end - # - # local args_with_theme = require("telescope.themes").get_dropdown(args) - # - # if extension ~= "" then - # require("telescope").extensions[extension][fn](args_with_theme) - # else - # require("telescope.builtin")[fn](args_with_theme) - # end - # end - # ''; + extraConfigLuaPre = '' + local telescopeWithArgs = function(fn, args, extension) + -- args.layout_config = { + -- anchor = "N", + -- mirror = true, + -- width = 0.8, + -- } + + -- if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end + + -- local args_with_theme = require("telescope.themes").get_dropdown(args) + local args_with_theme = args - # Use root keymaps to allow usage of custom TelescopeWithTheme function + if extension ~= "" then + require("telescope").extensions[extension][fn](args_with_theme) + else + require("telescope.builtin")[fn](args_with_theme) + end + end + ''; + + # Use root keymaps to allow usage of custom telescopeWithArgs function keymaps = let mkTelescopeKeymap = @@ -68,7 +69,7 @@ }: { inherit key mode; - action.__raw = "function() TelescopeWithTheme('${fn}', ${helpers.toLuaObject args}, '${builtins.toString extension}') end"; + action.__raw = "function() telescopeWithArgs('${fn}', ${helpers.toLuaObject args}, '${builtins.toString extension}') end"; options = { inherit desc; }; }; in