nvim: add Telescope picker for files from installed plugins

This commit is contained in:
Fernando Schauenburg 2025-07-01 17:12:34 +02:00
parent b620c0a997
commit 1ccbe82506

View file

@ -23,6 +23,7 @@ local pickers = setmetatable({
colorscheme = builtin("colorscheme", { enable_preview = true }), colorscheme = builtin("colorscheme", { enable_preview = true }),
diagnostics = builtin("diagnostics", { bufnr = 0 }), diagnostics = builtin("diagnostics", { bufnr = 0 }),
dotfiles = builtin("find_files", { cwd = "~/.dotfiles", hidden = true }), dotfiles = builtin("find_files", { cwd = "~/.dotfiles", hidden = true }),
plugins = builtin("find_files", { cwd = vim.fn.stdpath("data") .. "/lazy" }),
selection = function(title) selection = function(title)
return function() return function()
local text = require("fschauen.util").get_selected_text() local text = require("fschauen.util").get_selected_text()
@ -57,52 +58,6 @@ local keymap = function(spec)
}) })
end 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 { return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
@ -115,8 +70,54 @@ return {
cmd = "Telescope", cmd = "Telescope",
---@diagnostic disable-next-line: param-type-mismatch keys = vim
keys = vim.iter(keys):map(keymap):totable(), .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. -- Export this function so we can use in other plugins.
keymap = keymap, keymap = keymap,