diff options
author | christianchiarulli <[email protected]> | 2021-08-29 14:17:32 -0400 |
---|---|---|
committer | christianchiarulli <[email protected]> | 2021-08-29 14:17:32 -0400 |
commit | ed5559d259e38a78796a7d81421f02ba6dafac4b (patch) | |
tree | afa9c00c017382bac547265a8a1e16b9770a07eb /lua/core/telescope.lua | |
parent | e7b6d3b6f5982ea1042ffd499a7b85c18f0b782e (diff) | |
parent | c7a5122fe2c14dba0f28f1c077f838f957884afc (diff) |
Merge branch 'rolling' of github.com:ChristianChiarulli/LunarVim
Diffstat (limited to 'lua/core/telescope.lua')
-rw-r--r-- | lua/core/telescope.lua | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index f4d154b0..4ae56df0 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -1,13 +1,19 @@ local M = {} -local Log = require "core.log" -M.config = function() + +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 = { - active = false, + lvim.builtin.telescope = vim.tbl_extend("force", lvim.builtin.telescope, { defaults = { prompt_prefix = " ", selection_caret = " ", @@ -60,8 +66,8 @@ M.config = function() -- ["<CR>"] = actions.select_default + actions.center + my_cool_custom_action, }, n = { - ["<C-j>"] = actions.move_selection_next, - ["<C-k>"] = actions.move_selection_previous, + ["<C-n>"] = actions.move_selection_next, + ["<C-p>"] = actions.move_selection_previous, ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, -- ["<c-t>"] = trouble.open_with_trouble, -- ["<C-i>"] = my_cool_custom_action, @@ -74,16 +80,54 @@ M.config = function() override_file_sorter = true, }, }, + }) +end + +function M.find_lunarvim_files(opts) + opts = opts or {} + local themes = require "telescope.themes" + local theme_opts = themes.get_ivy { + previewer = false, + sorting_strategy = "ascending", + layout_strategy = "bottom_pane", + layout_config = { + height = 5, + width = 0.5, + }, + prompt = ">> ", + prompt_title = "~ LunarVim files ~", + cwd = CONFIG_PATH, + find_command = { "git", "ls-files" }, } + opts = vim.tbl_deep_extend("force", theme_opts, opts) + require("telescope.builtin").find_files(opts) end -M.setup = function() - local status_ok, telescope = pcall(require, "telescope") - if not status_ok then - Log:get_default().error "Failed to load telescope" - return - end +function M.grep_lunarvim_files(opts) + opts = opts or {} + local themes = require "telescope.themes" + local theme_opts = themes.get_ivy { + sorting_strategy = "ascending", + layout_strategy = "bottom_pane", + prompt = ">> ", + prompt_title = "~ search LunarVim ~", + cwd = CONFIG_PATH, + } + opts = vim.tbl_deep_extend("force", theme_opts, opts) + require("telescope.builtin").live_grep(opts) +end + +function M.setup() + local telescope = require "telescope" + telescope.setup(lvim.builtin.telescope) + if lvim.builtin.project.active then + telescope.load_extension "projects" + end + + if lvim.builtin.telescope.on_config_done then + lvim.builtin.telescope.on_config_done(telescope) + end end return M |