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,7 +58,20 @@ local keymap = function(spec)
}) })
end end
local keys = { return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-telescope/telescope-fzf-native.nvim",
build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release "
.. "&& cmake --build build --config Release "
.. "&& cmake --install build --prefix build",
},
cmd = "Telescope",
keys = vim
.iter({
-- stylua: ignore start -- stylua: ignore start
{ "a", pickers.autocommands " Autocommands" , desc = "[a]utocommands" }, { "a", pickers.autocommands " Autocommands" , desc = "[a]utocommands" },
{ "b", pickers.buffers " Buffers" , desc = "[b]uffers" }, { "b", pickers.buffers " Buffers" , desc = "[b]uffers" },
@ -81,7 +95,7 @@ local keys = {
{ "m", pickers.all_man_pages " Man pages" , desc = "[m]an pages" }, { "m", pickers.all_man_pages " Man pages" , desc = "[m]an pages" },
--"n" used in vim-notify --"n" used in vim-notify
{ "o", pickers.vim_options " Vim options" , desc = "[o]ptions" }, { "o", pickers.vim_options " Vim options" , desc = "[o]ptions" },
--"p" { "p", pickers.plugins " Installed Plugins" , desc = "[p]lugins" },
{ "q", pickers.quickfix " Quickfix" , desc = "[q]uickfix" }, { "q", pickers.quickfix " Quickfix" , desc = "[q]uickfix" },
{ "r", pickers.lsp_references " References" , desc = "[r]eferences" }, { "r", pickers.lsp_references " References" , desc = "[r]eferences" },
{ "R", pickers.registers "󱓥 Registers" , desc = "[R]registers" }, { "R", pickers.registers "󱓥 Registers" , desc = "[R]registers" },
@ -101,22 +115,9 @@ local keys = {
{ "/", pickers.search_history " Search history" , desc = "[/]search history" }, { "/", pickers.search_history " Search history" , desc = "[/]search history" },
{ " ", pickers.resume "󰐎 Resume" , desc = "Resume " }, { " ", pickers.resume "󰐎 Resume" , desc = "Resume " },
-- stylua: ignore end -- stylua: ignore end
} })
:map(keymap)
return { :totable(),
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-telescope/telescope-fzf-native.nvim",
build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release "
.. "&& cmake --build build --config Release "
.. "&& cmake --install build --prefix build",
},
cmd = "Telescope",
---@diagnostic disable-next-line: param-type-mismatch
keys = vim.iter(keys):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,