From 013d8189a6043c5e918dcc3788590c5ae22a64fb Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Thu, 15 Aug 2024 17:43:17 +0200 Subject: [PATCH] moved telescope to own config --- lua/plugins.lua | 63 +++------------------------------------ lua/plugins/telescope.lua | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 59 deletions(-) create mode 100644 lua/plugins/telescope.lua diff --git a/lua/plugins.lua b/lua/plugins.lua index 23824f7..88acf94 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,6 +1,3 @@ -local execute = vim.api.nvim_command -local fn = vim.fn - local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system( @@ -19,23 +16,6 @@ vim.opt.rtp:prepend(lazypath) local quick_prompts = { ["Code actions"] = true } -local selectX = function(n) - return function(bufnr) - local a = require("telescope.actions") - local s = require("telescope.actions.state") - local picker_name = s.get_current_picker(bufnr).prompt_title - if not quick_prompts[picker_name] then - -- Disable quick prompts to not press by accident - -- TODO: Still type the number - return - end - a.move_to_top(bufnr) - for _ = 1, n - 1 do - a.move_selection_next(bufnr) - end - a.select_default(bufnr) - end -end require("lazy").setup( { @@ -110,44 +90,7 @@ require("lazy").setup( { "nvim-telescope/telescope.nvim", config = function() - local dropdown_configs = { - layout_config = { - prompt_position = "top", - vertical = { - width = 80, - height = 12 - } - }, - border = {} - } - require("telescope").setup { - file_ignore_patterns = {"package-lock.json"}, - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown(dropdown_configs) - } - }, - defaults = { - mappings = { - i = { - [""] = "close", - ["n"] = {require("telescope.actions").move_selection_next, type = "action"}, - ["1"] = {selectX(1), type = "action"}, - ["2"] = {selectX(2), type = "action"}, - ["3"] = {selectX(3), type = "action"}, - ["4"] = {selectX(4), type = "action"}, - ["5"] = {selectX(5), type = "action"}, - ["6"] = {selectX(6), type = "action"}, - ["7"] = {selectX(7), type = "action"}, - ["8"] = {selectX(8), type = "action"}, - ["9"] = {selectX(9), type = "action"}, - ["0"] = {selectX(10), type = "action"} - }, - n = {} - } - } - } - require("telescope").load_extension("ui-select") + require("plugins/telescope") end, dependencies = { "nvim-lua/popup.nvim", @@ -217,7 +160,9 @@ require("lazy").setup( { "supermaven-inc/supermaven-nvim", config = function() - require("supermaven-nvim").setup({}) + if not (vim.fn.has_key(vim.fn.environ(), "LOAD_SUPERMAVEN") == 0) then + require("supermaven-nvim").setup({}) + end end }, { diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..b25b0ac --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,56 @@ +local selectX = function(n) + return function(bufnr) + local a = require("telescope.actions") + local s = require("telescope.actions.state") + local picker_name = s.get_current_picker(bufnr).prompt_title + if not quick_prompts[picker_name] then + -- Disable quick prompts to not press by accident + -- TODO: Still type the number + return + end + a.move_to_top(bufnr) + for _ = 1, n - 1 do + a.move_selection_next(bufnr) + end + a.select_default(bufnr) + end +end + +local dropdown_configs = { + layout_config = { + prompt_position = "top", + vertical = { + width = 80, + height = 12 + } + }, + border = {} +} + +require("telescope").setup { + file_ignore_patterns = {"package-lock.json"}, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown(dropdown_configs) + } + }, + defaults = { + mappings = { + i = { + [""] = "close", + ["1"] = {selectX(1), type = "action"}, + ["2"] = {selectX(2), type = "action"}, + ["3"] = {selectX(3), type = "action"}, + ["4"] = {selectX(4), type = "action"}, + ["5"] = {selectX(5), type = "action"}, + ["6"] = {selectX(6), type = "action"}, + ["7"] = {selectX(7), type = "action"}, + ["8"] = {selectX(8), type = "action"}, + ["9"] = {selectX(9), type = "action"}, + ["0"] = {selectX(10), type = "action"} + }, + n = {} + } + } +} +require("telescope").load_extension("ui-select")