diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index e726768a..22b67c90 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -165,48 +165,47 @@ return { desc = "Goto Symbol (Workspace)", }, }, - opts = { - defaults = { - prompt_prefix = " ", - selection_caret = " ", - mappings = { - i = { - [""] = function(...) - return require("trouble.providers.telescope").open_with_trouble(...) - end, - [""] = function(...) - return require("trouble.providers.telescope").open_selected_with_trouble(...) - end, - [""] = function() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - Util.telescope("find_files", { no_ignore = true, default_text = line })() - end, - [""] = function() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - Util.telescope("find_files", { hidden = true, default_text = line })() - end, - [""] = function(...) - return require("telescope.actions").cycle_history_next(...) - end, - [""] = function(...) - return require("telescope.actions").cycle_history_prev(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_down(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_up(...) - end, - }, - n = { - ["q"] = function(...) - return require("telescope.actions").close(...) - end, + opts = function() + local actions = require("telescope.actions") + + local open_with_trouble = function(...) + return require("trouble.providers.telescope").open_with_trouble(...) + end + local open_selected_with_trouble = function(...) + return require("trouble.providers.telescope").open_selected_with_trouble(...) + end + local find_files_no_ignore = function() + local action_state = require("telescope.actions.state") + local line = action_state.get_current_line() + Util.telescope("find_files", { no_ignore = true, default_text = line })() + end + local find_files_with_hidden = function() + local action_state = require("telescope.actions.state") + local line = action_state.get_current_line() + Util.telescope("find_files", { hidden = true, default_text = line })() + end + + return { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + mappings = { + i = { + [""] = open_with_trouble, + [""] = open_selected_with_trouble, + [""] = find_files_no_ignore, + [""] = find_files_with_hidden, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.preview_scrolling_down, + [""] = actions.preview_scrolling_up, + }, + n = { + ["q"] = actions.close, + }, }, }, - }, + } }, },