summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLostNeophyte <[email protected]>2022-12-08 12:11:13 +0100
committerGitHub <[email protected]>2022-12-08 12:11:13 +0100
commit245a71c9f7558423360c65c7d6ac7c6bbcd5cc2f (patch)
tree72228415ffa767a2ffe58c20a2bf816766074402
parent33e0960ba3fbe4988731a7e297d5f696993f8541 (diff)
feat(telescope): add `lvim.builtin.telescope.theme` (#3548)
fixes https://github.com/LunarVim/LunarVim/issues/3406
-rw-r--r--lua/lvim/core/telescope.lua129
-rw-r--r--lua/lvim/core/which-key.lua9
2 files changed, 58 insertions, 80 deletions
diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua
index 0cfe0b23..f07efe14 100644
--- a/lua/lvim/core/telescope.lua
+++ b/lua/lvim/core/telescope.lua
@@ -1,62 +1,10 @@
local M = {}
-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
+---@alias telescope_themes
+---| "cursor" # see `telescope.themes.get_cursor()`
+---| "dropdown" # see `telescope.themes.get_dropdown()`
+---| "ivy" # see `telescope.themes.get_ivy()`
+---| "center" # retain the default telescope theme
function M.config()
-- Define this minimal config so that it's available if telescope is not yet available.
@@ -71,29 +19,19 @@ function M.config()
if not ok then
return
end
- lvim.builtin.telescope = vim.tbl_extend("force", lvim.builtin.telescope, {
+ lvim.builtin.telescope = {
+ active = true,
+ on_config_done = nil,
+ theme = "dropdown", ---@type telescope_themes
defaults = {
prompt_prefix = lvim.icons.ui.Telescope .. " ",
selection_caret = lvim.icons.ui.Forward .. " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
- sorting_strategy = "descending",
- layout_strategy = "horizontal",
- layout_config = {
- width = 0.75,
- preview_cutoff = 120,
- horizontal = {
- preview_width = function(_, cols, _)
- if cols < 120 then
- return math.floor(cols * 0.5)
- end
- return math.floor(cols * 0.6)
- end,
- mirror = false,
- },
- vertical = { mirror = false },
- },
+ sorting_strategy = nil,
+ layout_strategy = nil,
+ layout_config = nil,
vimgrep_arguments = {
"rg",
"--color=never",
@@ -122,16 +60,45 @@ function M.config()
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
},
},
- pickers = get_pickers(actions),
file_ignore_patterns = {},
path_display = { "smart" },
winblend = 0,
border = {},
- borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
+ borderchars = nil,
color_devicons = true,
set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,
},
- pickers = get_pickers(actions),
+ pickers = {
+ find_files = {
+ hidden = true,
+ },
+ live_grep = {
+ --@usage don't include the filename in the search results
+ only_sort_text = true,
+ },
+ grep_string = {
+ only_sort_text = true,
+ },
+ buffers = {
+ initial_mode = "normal",
+ mappings = {
+ i = {
+ ["<C-d>"] = actions.delete_buffer,
+ },
+ n = {
+ ["dd"] = actions.delete_buffer,
+ },
+ },
+ },
+ planets = {
+ show_pluto = true,
+ show_moon = true,
+ },
+ git_files = {
+ hidden = true,
+ show_untracked = true,
+ },
+ },
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
@@ -140,7 +107,7 @@ function M.config()
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
},
},
- })
+ }
end
function M.setup()
@@ -156,6 +123,12 @@ function M.setup()
}, lvim.builtin.telescope)
local telescope = require "telescope"
+
+ local theme = require("telescope.themes")["get_" .. lvim.builtin.telescope.theme]
+ if theme then
+ lvim.builtin.telescope.defaults = theme(lvim.builtin.telescope.defaults)
+ end
+
telescope.setup(lvim.builtin.telescope)
if lvim.builtin.project.active then
diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua
index d0ad77a1..efc673a2 100644
--- a/lua/lvim/core/which-key.lua
+++ b/lua/lvim/core/which-key.lua
@@ -84,13 +84,18 @@ M.config = function()
["q"] = { "<cmd>lua require('lvim.utils.functions').smart_quit()<CR>", "Quit" },
["/"] = { "<Plug>(comment_toggle_linewise_current)", "Comment toggle current line" },
["c"] = { "<cmd>BufferKill<CR>", "Close Buffer" },
- ["f"] = { require("lvim.core.telescope.custom-finders").find_project_files, "Find File" },
+ ["f"] = {
+ function()
+ require("lvim.core.telescope.custom-finders").find_project_files { previewer = false }
+ end,
+ "Find File",
+ },
["h"] = { "<cmd>nohlsearch<CR>", "No Highlight" },
["e"] = { "<cmd>NvimTreeToggle<CR>", "Explorer" },
b = {
name = "Buffers",
j = { "<cmd>BufferLinePick<cr>", "Jump" },
- f = { "<cmd>Telescope buffers<cr>", "Find" },
+ f = { "<cmd>Telescope buffers previewer=false<cr>", "Find" },
b = { "<cmd>BufferLineCyclePrev<cr>", "Previous" },
n = { "<cmd>BufferLineCycleNext<cr>", "Next" },
W = { "<cmd>noautocmd w<cr>", "Save without formatting (noautocmd)" },