From aad55d856e14a85a7ba844abf692e4a4b94b89f0 Mon Sep 17 00:00:00 2001 From: LostNeophyte Date: Thu, 19 Jan 2023 13:48:23 +0100 Subject: simplify telescope actions --- lua/lvim/core/telescope.lua | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index b8bd1b1c..b701f7e4 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -7,18 +7,7 @@ local M = {} ---| "center" # retain the default telescope theme function M.config() - local lazy_action = function(name) - return function(...) - if type(name) == "table" then - for _, n in ipairs(name) do - require("telescope.actions")[n](...) - end - return - end - require("telescope.actions")[name](...) - end - end - + local actions = require("lvim.utils.modules").require_on_exported_call "telescope.actions" lvim.builtin.telescope = { ---@usage disable telescope completely [not recommended] active = true, @@ -47,18 +36,24 @@ function M.config() ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults. mappings = { i = { - [""] = lazy_action "move_selection_next", - [""] = lazy_action "move_selection_previous", - [""] = lazy_action "close", - [""] = lazy_action "cycle_history_next", - [""] = lazy_action "cycle_history_prev", - [""] = lazy_action { "smart_send_to_qflist", "open_qflist" }, - [""] = lazy_action "select_default", + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.close, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = function(...) + actions.smart_send_to_qflist(...) + actions.open_qflist(...) + end, + [""] = actions.select_default, }, n = { - [""] = lazy_action "move_selection_next", - [""] = lazy_action "move_selection_previous", - [""] = lazy_action { "smart_send_to_qflist", "open_qflist" }, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = function(...) + actions.smart_send_to_qflist(...) + actions.open_qflist(...) + end, }, }, file_ignore_patterns = {}, @@ -84,10 +79,10 @@ function M.config() initial_mode = "normal", mappings = { i = { - [""] = lazy_action "delete_buffer", + [""] = actions.delete_buffer, }, n = { - ["dd"] = lazy_action "delete_buffer", + ["dd"] = actions.delete_buffer, }, }, }, -- cgit v1.2.3