From 61b1f01bde8b83f13e87f08b411484f5646627f4 Mon Sep 17 00:00:00 2001 From: Randall Mason Date: Sun, 13 Mar 2022 22:52:56 -0500 Subject: [PATCH] Modularize theme selection for whichkey's telescope commands Currently, each whichkey is configured slightly differently based on the type of theme used for it. This makes them all structured the same so that it's easier to switch between dropdown or ivy. The nice thing is that one can then replace ivy{} with dropdown{} more easily. --- lua/user/whichkey.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/user/whichkey.lua b/lua/user/whichkey.lua index 11b6a7ea3..6e784eac2 100644 --- a/lua/user/whichkey.lua +++ b/lua/user/whichkey.lua @@ -78,10 +78,14 @@ local opts = { nowait = true, -- use `nowait` when creating keymaps } +local buffer_theme = "dropdown{previewer = false}" +local find_file_theme = "dropdown{previewer = false}" +local find_text_theme = "ivy{}" + local mappings = { ["a"] = { "Alpha", "Alpha" }, ["b"] = { - "lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})", + "lua require('telescope.builtin').buffers(require('telescope.themes').get_" .. buffer_theme .. ")", "Buffers", }, ["e"] = { "NvimTreeToggle", "Explorer" }, @@ -90,10 +94,13 @@ local mappings = { ["c"] = { "Bdelete!", "Close Buffer" }, ["h"] = { "nohlsearch", "No Highlight" }, ["f"] = { - "lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})", + "lua require('telescope.builtin').find_files(require('telescope.themes').get_" .. find_file_theme .. ")", "Find files", }, - ["F"] = { "Telescope live_grep theme=ivy", "Find Text" }, + ["F"] = { + "lua require('telescope.builtin').live_grep(require('telescope.themes').get_" .. find_text_theme .. ")", + "Find text", + }, ["P"] = { "lua require('telescope').extensions.projects.projects()", "Projects" }, p = {