feat(plugins/telescope): allow to run extension with theme

This commit is contained in:
Nicolas Goudry 2024-06-10 00:13:25 +02:00
parent 488bf61523
commit 9183c5dca3
No known key found for this signature in database
GPG key ID: 5FC434D9FFD1DF44

View file

@ -36,7 +36,7 @@
# │ └────────────────────────────────────────┘ │
# └──────────────────────────────────────────────────┘
extraConfigLuaPre = ''
local TelescopeWithTheme = function(fn, args)
local TelescopeWithTheme = function(fn, args, extension)
args.layout_config = {
anchor = "N",
mirror = true,
@ -45,7 +45,13 @@
if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end
require("telescope.builtin")[fn](require("telescope.themes").get_dropdown(args))
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
'';
@ -54,14 +60,15 @@
let
mkTelescopeKeymap =
{ key
, mode ? "n"
, fn
, args ? { __empty = true; }
, desc ? ""
, extension ? null
, mode ? "n"
}: {
inherit key mode;
action.__raw = "function() TelescopeWithTheme('${fn}', ${helpers.toLuaObject args}) end";
action.__raw = "function() TelescopeWithTheme('${fn}', ${helpers.toLuaObject args}, '${builtins.toString extension}') end";
options = { inherit desc; };
};
in