From 1ccbe825060d632c74f2b5fcd74658fa6c001bc6 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Tue, 1 Jul 2025 17:12:34 +0200 Subject: [PATCH] nvim: add Telescope picker for files from installed plugins --- .../nvim/lua/fschauen/plugins/telescope.lua | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/config/nvim/lua/fschauen/plugins/telescope.lua b/config/nvim/lua/fschauen/plugins/telescope.lua index 605cfc0..aa7fe96 100644 --- a/config/nvim/lua/fschauen/plugins/telescope.lua +++ b/config/nvim/lua/fschauen/plugins/telescope.lua @@ -23,6 +23,7 @@ local pickers = setmetatable({ colorscheme = builtin("colorscheme", { enable_preview = true }), diagnostics = builtin("diagnostics", { bufnr = 0 }), dotfiles = builtin("find_files", { cwd = "~/.dotfiles", hidden = true }), + plugins = builtin("find_files", { cwd = vim.fn.stdpath("data") .. "/lazy" }), selection = function(title) return function() local text = require("fschauen.util").get_selected_text() @@ -57,52 +58,6 @@ local keymap = function(spec) }) end -local keys = { - -- stylua: ignore start - { "a", pickers.autocommands " Autocommands" , desc = "[a]utocommands" }, - { "b", pickers.buffers " Buffers" , desc = "[b]uffers" }, - --"B" used in telescope-file-browser - { "c", pickers.colorscheme " Colorschemes" , desc = "[c]olorschemes" }, - { "C", pickers.commands " Commands" , desc = "[C]ommands" }, - { "d", pickers.diagnostics "󰀪 Diagnostics" , desc = "[d]iagnostics" }, - --"e" - { "f", pickers.find_files " Files" , desc = "[f]ind files" }, - { "F", pickers.all_files " ALL files" , desc = "all [F]iles" }, - { "gr", pickers.live_grep " Live grep" , desc = "Live [gr]ep" }, - { "gf", pickers.git_files " Git files" , desc = "[g]it [f]iles" }, - { "gc", pickers.git_commits " Commits" , desc = "[g]it [c]ommits" }, - { "h", pickers.here " Current buffer" , desc = "[b]uffer [h]ere" }, - { "H", pickers.highlights "󰌶 Highlights" , desc = "[H]ighlights" }, - --"i" used in nerdy - { "j", pickers.jumplist " Jumplist" , desc = "[j]umplist" }, - { "k", pickers.keymaps " Keymaps" , desc = "[k]eymaps" }, - { "K", pickers.help_tags " Help tags" , desc = "[K] help/documentation" }, - { "l", pickers.loclist " Location list" , desc = "[l]ocation List" }, - { "m", pickers.all_man_pages " Man pages" , desc = "[m]an pages" }, - --"n" used in vim-notify - { "o", pickers.vim_options " Vim options" , desc = "[o]ptions" }, - --"p" - { "q", pickers.quickfix " Quickfix" , desc = "[q]uickfix" }, - { "r", pickers.lsp_references " References" , desc = "[r]eferences" }, - { "R", pickers.registers "󱓥 Registers" , desc = "[R]registers" }, - { "s", pickers.lsp_document_symbols "󰫧 Document Symbols " , desc = "LSP document [s]ymbols" }, - { "S", pickers.lsp_workspace_symbols "󱄑 Workspace Symbols " , desc = "LSP workspace [S]ymbols" }, - --"t" used in todo_comments - { "T", pickers.treesitter " Treesitter symbols" , desc = "[T]reesitter Symbols" }, - --"u" - --"v" - { "w", pickers.selection " Grep" , desc = "[w]word under cursor" }, - { "w", pickers.selection " Grep", mode = "v" , desc = "[w]ord(s) selected" }, - --"x" - --"y" - { "z", pickers.spell_suggest "󰓆 Spelling suggestions" , desc = "[z] spell suggestions" }, - { ".", pickers.dotfiles " Dotfiles" , desc = "[.]dotfiles" }, - { ":", pickers.command_history " Command history" , desc = "[:]command history" }, - { "/", pickers.search_history " Search history" , desc = "[/]search history" }, - { " ", pickers.resume "󰐎 Resume" , desc = "Resume " }, - -- stylua: ignore end -} - return { "nvim-telescope/telescope.nvim", @@ -115,8 +70,54 @@ return { cmd = "Telescope", - ---@diagnostic disable-next-line: param-type-mismatch - keys = vim.iter(keys):map(keymap):totable(), + keys = vim + .iter({ + -- stylua: ignore start + { "a", pickers.autocommands " Autocommands" , desc = "[a]utocommands" }, + { "b", pickers.buffers " Buffers" , desc = "[b]uffers" }, + --"B" used in telescope-file-browser + { "c", pickers.colorscheme " Colorschemes" , desc = "[c]olorschemes" }, + { "C", pickers.commands " Commands" , desc = "[C]ommands" }, + { "d", pickers.diagnostics "󰀪 Diagnostics" , desc = "[d]iagnostics" }, + --"e" + { "f", pickers.find_files " Files" , desc = "[f]ind files" }, + { "F", pickers.all_files " ALL files" , desc = "all [F]iles" }, + { "gr", pickers.live_grep " Live grep" , desc = "Live [gr]ep" }, + { "gf", pickers.git_files " Git files" , desc = "[g]it [f]iles" }, + { "gc", pickers.git_commits " Commits" , desc = "[g]it [c]ommits" }, + { "h", pickers.here " Current buffer" , desc = "[b]uffer [h]ere" }, + { "H", pickers.highlights "󰌶 Highlights" , desc = "[H]ighlights" }, + --"i" used in nerdy + { "j", pickers.jumplist " Jumplist" , desc = "[j]umplist" }, + { "k", pickers.keymaps " Keymaps" , desc = "[k]eymaps" }, + { "K", pickers.help_tags " Help tags" , desc = "[K] help/documentation" }, + { "l", pickers.loclist " Location list" , desc = "[l]ocation List" }, + { "m", pickers.all_man_pages " Man pages" , desc = "[m]an pages" }, + --"n" used in vim-notify + { "o", pickers.vim_options " Vim options" , desc = "[o]ptions" }, + { "p", pickers.plugins " Installed Plugins" , desc = "[p]lugins" }, + { "q", pickers.quickfix " Quickfix" , desc = "[q]uickfix" }, + { "r", pickers.lsp_references " References" , desc = "[r]eferences" }, + { "R", pickers.registers "󱓥 Registers" , desc = "[R]registers" }, + { "s", pickers.lsp_document_symbols "󰫧 Document Symbols " , desc = "LSP document [s]ymbols" }, + { "S", pickers.lsp_workspace_symbols "󱄑 Workspace Symbols " , desc = "LSP workspace [S]ymbols" }, + --"t" used in todo_comments + { "T", pickers.treesitter " Treesitter symbols" , desc = "[T]reesitter Symbols" }, + --"u" + --"v" + { "w", pickers.selection " Grep" , desc = "[w]word under cursor" }, + { "w", pickers.selection " Grep", mode = "v" , desc = "[w]ord(s) selected" }, + --"x" + --"y" + { "z", pickers.spell_suggest "󰓆 Spelling suggestions" , desc = "[z] spell suggestions" }, + { ".", pickers.dotfiles " Dotfiles" , desc = "[.]dotfiles" }, + { ":", pickers.command_history " Command history" , desc = "[:]command history" }, + { "/", pickers.search_history " Search history" , desc = "[/]search history" }, + { " ", pickers.resume "󰐎 Resume" , desc = "Resume " }, + -- stylua: ignore end + }) + :map(keymap) + :totable(), -- Export this function so we can use in other plugins. keymap = keymap,