From d85584d09f9028fa4202cea473f7f0ae3c531aef Mon Sep 17 00:00:00 2001 From: devtoi <508254+devtoi@users.noreply.github.com> Date: Sun, 22 Aug 2021 20:03:19 +0200 Subject: [Refactor/Bugfix] move on_config_done callbacks to relevant setup() (#1175) * Make autopairs config consistent with others * Fix two typos for autopairs * Remove extranous autopairs code. Return on setup * Remove extranous else for autopairs completion confirmation * Move on_config_done callbacks to setup functions. * Add on_config_done completion for builtins lacking a config function * enables galaxyline callbacks to work properly * Add modules for more builtins * Finish streamline of config function in plugin setup * Fix double use of which_key/wk * Fix erroneous remove of functionality in autopairs completion * consistency fixes * Work around telescope not found at config time * Match plugin definition of project and lualine with others * fix: restore config callback syntax Co-authored-by: Johan Melin Co-authored-by: rebuilt Co-authored-by: Luc Sinet Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com> --- lua/core/telescope.lua | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'lua/core/telescope.lua') diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 5d9263d7..4ae56df0 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -1,13 +1,19 @@ local M = {} + function M.config() + -- Define this minimal config so that it's available if telescope is not yet available. + lvim.builtin.telescope = { + ---@usage disable telescope completely [not recommeded] + active = true, + on_config_done = nil, + } + local status_ok, actions = pcall(require, "telescope.actions") if not status_ok then return end - lvim.builtin.telescope = { - ---@usage disable telescope completely [not recommeded] - active = true, + lvim.builtin.telescope = vim.tbl_extend("force", lvim.builtin.telescope, { defaults = { prompt_prefix = " ", selection_caret = " ", @@ -74,7 +80,7 @@ function M.config() override_file_sorter = true, }, }, - } + }) end function M.find_lunarvim_files(opts) @@ -112,15 +118,15 @@ function M.grep_lunarvim_files(opts) end function M.setup() - local status_ok, telescope = pcall(require, "telescope") - if not status_ok then - local Log = require "core.log" - Log:get_default().error "Failed to load telescope" - return - end + local telescope = require "telescope" + telescope.setup(lvim.builtin.telescope) if lvim.builtin.project.active then - pcall(require("telescope").load_extension, "projects") + telescope.load_extension "projects" + end + + if lvim.builtin.telescope.on_config_done then + lvim.builtin.telescope.on_config_done(telescope) end end -- cgit v1.2.3