diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-11-08 23:13:05 +0100 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-11-08 23:13:05 +0100 |
commit | c9e2adbbc8fd7a5398c8c66d21f0e02dc7b60203 (patch) | |
tree | 274263ba15e0197180af8bb681e22c4780d5de05 /.config/nvim/lua/core/telescope.lua | |
parent | e4ea22e223bbd6b4091610c6fa093862cbd32f75 (diff) |
Add new lunarvin updates
Diffstat (limited to '.config/nvim/lua/core/telescope.lua')
-rw-r--r-- | .config/nvim/lua/core/telescope.lua | 126 |
1 files changed, 79 insertions, 47 deletions
diff --git a/.config/nvim/lua/core/telescope.lua b/.config/nvim/lua/core/telescope.lua index 108b6f3..7ef2e58 100644 --- a/.config/nvim/lua/core/telescope.lua +++ b/.config/nvim/lua/core/telescope.lua @@ -15,14 +15,6 @@ function M.config() options.builtin.telescope = vim.tbl_extend("force", options.builtin.telescope, { defaults = { - find_command = { - "rg", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, prompt_prefix = " ", selection_caret = " ", entry_prefix = " ", @@ -37,55 +29,55 @@ function M.config() horizontal = { mirror = false }, vertical = { mirror = false }, }, - file_sorter = require("telescope.sorters").get_fzy_sorter, - file_ignore_patterns = {}, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - path_display = { "shorten" }, - winblend = 0, - border = {}, - borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - color_devicons = true, - use_less = true, - set_env = { ["CoptionsLoptionsRTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - - -- Developer configurations: Not meant for general override - -- buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + "--hidden", + }, mappings = { i = { - -- ["<C-n>"] = actions.cycle_history_next, - -- ["<C-p>"] = actions.cycle_history_prev, + ["<C-n>"] = actions.move_selection_next, + ["<C-p>"] = actions.move_selection_previous, ["<C-c>"] = actions.close, - ["<C-j>"] = actions.move_selection_next, - ["<C-k>"] = actions.move_selection_previous, + ["<C-j>"] = actions.cycle_history_next, + ["<C-k>"] = actions.cycle_history_prev, ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, ["<CR>"] = actions.select_default + actions.center, - -- To disable a keymap, put [map] = false - -- So, to not map "<C-n>", just put - -- ["<c-t>"] = trouble.open_with_trouble, - -- ["<c-x>"] = false, - -- ["<esc>"] = actions.close, - -- optionstherwise, just set the mapping to the function that you want it to be. - -- ["<C-i>"] = actions.select_horizontal, - -- Add up multiple actions - -- You can perform as many actions in a row as you like - -- ["<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, + }, + }, + file_ignore_patterns = {}, + path_display = { shorten = 5 }, + winblend = 0, + border = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + color_devicons = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + pickers = { + find_files = { + find_command = { "fd", "--type=file", "--hidden", "--smart-case" }, + }, + live_grep = { + --@usage don't include the filename in the search results + only_sort_text = true, }, }, }, extensions = { - fzy_native = { - override_generic_sorter = false, - override_file_sorter = true, + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" }, }, }) @@ -108,20 +100,60 @@ function M.code_actions() previewer = false, shorten_path = false, } - require("telescope.builtin").lsp_code_actions(require("telescope.themes").get_dropdown(opts)) + require("telescope.builtin").lsp_code_actions( + require("telescope.themes").get_dropdown(opts) + ) end function M.setup() + local previewers = require "telescope.previewers" + local sorters = require "telescope.sorters" + local actions = require "telescope.actions" + + options.builtin.telescope = vim.tbl_extend("keep", { + file_previewer = previewers.vim_buffer_cat.new, + grep_previewer = previewers.vim_buffer_vimgrep.new, + qflist_previewer = previewers.vim_buffer_qflist.new, + file_sorter = sorters.get_fuzzy_file, + generic_sorter = sorters.get_generic_fuzzy_sorter, + ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults. + mappings = { + i = { + ["<C-n>"] = actions.move_selection_next, + ["<C-p>"] = actions.move_selection_previous, + ["<C-c>"] = actions.close, + ["<C-j>"] = actions.cycle_history_next, + ["<C-k>"] = actions.cycle_history_prev, + ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, + ["<CR>"] = actions.select_default + actions.center, + }, + n = { + ["<C-n>"] = actions.move_selection_next, + ["<C-p>"] = actions.move_selection_previous, + ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, + }, + }, + }, options.builtin.telescope) + local telescope = require "telescope" telescope.setup(options.builtin.telescope) + if options.builtin.project.active then - telescope.load_extension "projects" + pcall(function() + require("telescope").load_extension "projects" + end) end if options.builtin.telescope.on_config_done then options.builtin.telescope.on_config_done(telescope) end + + if + options.builtin.telescope.extensions and options.builtin.telescope.extensions.fzf + then + require("telescope").load_extension "fzf" + end end return M |