diff options
Diffstat (limited to 'lua/lvim')
| -rw-r--r-- | lua/lvim/core/telescope.lua | 130 | 
1 files changed, 60 insertions, 70 deletions
| diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index 6e614dd9..77bf552d 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -1,52 +1,62 @@  local M = {} -local pickers = { -  find_files = { -    theme = "dropdown", -    hidden = true, -    previewer = false, -  }, -  live_grep = { -    --@usage don't include the filename in the search results -    only_sort_text = true, -    theme = "dropdown", -  }, -  grep_string = { -    only_sort_text = true, -    theme = "dropdown", -  }, -  buffers = { -    theme = "dropdown", -    previewer = false, -    initial_mode = "normal", -  }, -  planets = { -    show_pluto = true, -    show_moon = true, -  }, -  git_files = { -    theme = "dropdown", -    hidden = true, -    previewer = false, -    show_untracked = true, -  }, -  lsp_references = { -    theme = "dropdown", -    initial_mode = "normal", -  }, -  lsp_definitions = { -    theme = "dropdown", -    initial_mode = "normal", -  }, -  lsp_declarations = { -    theme = "dropdown", -    initial_mode = "normal", -  }, -  lsp_implementations = { -    theme = "dropdown", -    initial_mode = "normal", -  }, -} +local function get_pickers(actions) +  return { +    find_files = { +      theme = "dropdown", +      hidden = true, +      previewer = false, +    }, +    live_grep = { +      --@usage don't include the filename in the search results +      only_sort_text = true, +      theme = "dropdown", +    }, +    grep_string = { +      only_sort_text = true, +      theme = "dropdown", +    }, +    buffers = { +      theme = "dropdown", +      previewer = false, +      initial_mode = "normal", +      mappings = { +        i = { +          ["<C-d>"] = actions.delete_buffer, +        }, +        n = { +          ["dd"] = actions.delete_buffer, +        }, +      }, +    }, +    planets = { +      show_pluto = true, +      show_moon = true, +    }, +    git_files = { +      theme = "dropdown", +      hidden = true, +      previewer = false, +      show_untracked = true, +    }, +    lsp_references = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +    lsp_definitions = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +    lsp_declarations = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +    lsp_implementations = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +  } +end  function M.config()    -- Define this minimal config so that it's available if telescope is not yet available. @@ -95,6 +105,7 @@ function M.config()          "--hidden",          "--glob=!.git/",        }, +      ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults.        mappings = {          i = {            ["<C-n>"] = actions.move_selection_next, @@ -104,16 +115,14 @@ function M.config()            ["<C-k>"] = actions.cycle_history_prev,            ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,            ["<CR>"] = actions.select_default, -          ["<C-d>"] = require("telescope.actions").delete_buffer,          },          n = {            ["<C-n>"] = actions.move_selection_next,            ["<C-p>"] = actions.move_selection_previous,            ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, -          ["dd"] = require("telescope.actions").delete_buffer,          },        }, -      pickers = pickers, +      pickers = get_pickers(actions),        file_ignore_patterns = {},        path_display = { "smart" },        winblend = 0, @@ -122,7 +131,7 @@ function M.config()        color_devicons = true,        set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,      }, -    pickers = pickers, +    pickers = get_pickers(actions),      extensions = {        fzf = {          fuzzy = true, -- false will only do exact matching @@ -137,7 +146,6 @@ end  function M.setup()    local previewers = require "telescope.previewers"    local sorters = require "telescope.sorters" -  local actions = require "telescope.actions"    lvim.builtin.telescope = vim.tbl_extend("keep", {      file_previewer = previewers.vim_buffer_cat.new, @@ -145,24 +153,6 @@ function M.setup()      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, -        ["dd"] = require("telescope.actions").delete_buffer, -      }, -    },    }, lvim.builtin.telescope)    local telescope = require "telescope" | 
