Telescope extension that provides handy functionality about plugins installed via lazy.nvim
telescope-lazy.nvim
Telescope extension that provides handy functionality about plugins installed via lazy.nvim.
Demo
Dependencies
Required:
Optional:Installation
Lazy
{ "nvim-telescope/telescope.nvim", dependencies = "tsakirist/telescope-lazy.nvim" }
Configuration
Example setup:
require("telescope").setup({
extensions = {
-- Type information can be loaded via 'https://github.com/folke/lazydev.nvim'
-- by adding the below two annotations:
---@module "telescope._extensions.lazy"
---@type TelescopeLazy.Config
lazy = {
-- What icon to show on the first column of the picker
icon = "๏ฆ",
-- Optional theme (the extension doesn't set a default theme)
theme = "ivy",
-- The below configuration options are the defaults
show_icon = true,
mappings = {
openinbrowser = "<C-o>",
openinfile_browser = "<M-b>",
openinfind_files = "<C-f>",
openinlive_grep = "<C-g>",
openinterminal = "<C-t>",
openpluginspicker = "<C-b>",
openlazyrootfindfiles = "<C-r>f",
openlazyrootlivegrep = "<C-r>g",
changecwdto_plugin = "<C-c>d",
},
actions_opts = {
openinbrowser = {
auto_close = false,
},
changecwdto_plugin = {
auto_close = false,
},
},
custom_actions = {
["<C-p>"] = function(promptbufnr, selectedentry)
-- Do something with the selected_entry
dbg(selected_entry)
-- Optionally close the lazy picker
require("telescope.actions").close(prompt_bufnr)
end,
},
terminal_opts = {
relative = "editor",
style = "minimal",
border = "rounded",
title = "Telescope lazy",
title_pos = "center",
width = 0.5,
height = 0.5,
},
-- Other telescope configuration options
},
},
})
require("telescope").load_extension("lazy")
Default settings
---@type TelescopeLazy.Config
local defaults = {
-- What icon to show on the first column of the picker
icon = "๏ฆ",
-- Whether or not to show the icon in the first column
show_icon = true,
-- Mappings for the actions
mappings = {
openinbrowser = "<C-o>",
openinfile_browser = "<M-b>",
openinfind_files = "<C-f>",
openinlive_grep = "<C-g>",
openinterminal = "<C-t>",
openpluginspicker = "<C-b>", -- Works only after having called first another action
openlazyrootfindfiles = "<C-r>f",
openlazyrootlivegrep = "<C-r>g",
changecwdto_plugin = "<C-c>d",
},
-- Extra configuration options for the actions
actions_opts = {
openinbrowser = {
-- Close the telescope window after the action is executed
auto_close = false,
},
changecwdto_plugin = {
-- Close the telescope window after the action is executed
auto_close = false,
},
},
-- Custom actions to be added to the picker
custom_actions = {},
-- Configuration that will be passed to the window that hosts the terminal
-- For more configuration options check 'nvimopenwin()'
terminal_opts = {
relative = "editor",
style = "minimal",
border = "rounded",
title = "Telescope lazy",
title_pos = "center",
width = 0.5,
height = 0.5,
},
}
Types
---@class TelescopeLazy.Config
---@field icon? string The icon to show on the first column of the picker.
---@field show_icon? boolean Whether or not to show the icon in the first column of the picker.
---@field mappings? TelescopeLazy.Mappings Mappings for the picker actions.
---@field actions_opts? TelescopeLazy.ActionsOpts Configuration options for the picker actions.
---@field terminalopts? vim.api.keyset.winconfig Configuration for the terminal window action.
---@field custom_actions? table<string, TelescopeLazy.CustomAction> Custom actions to be added to the picker.
---@field theme? TelescopeLazy.Theme The Telescope theme to use for the picker.
---@alias TelescopeLazy.CustomAction fun(promptbufnr: integer, selectedentry: TelescopeLazy.Plugin) ---@alias TelescopeLazy.Theme "dropdown" | "cursor" |"ivy"
---@class TelescopeLazy.Mappings ---@field openinbrowser? string ---@field openinfile_browser? string ---@field openinfind_files? string ---@field openinlive_grep? string ---@field openinterminal? string ---@field openpluginspicker? string ---@field openlazyrootfindfiles? string ---@field openlazyrootlivegrep? string ---@field changecwdto_plugin? string
---@class TelescopeLazy.ActionOpts ---@field auto_close? boolean Automatically close the telescope window after the action is executed.
---@class TelescopeLazy.ActionsOpts ---@field openinbrowser TelescopeLazy.ActionOpts ---@field changecwdto_plugin TelescopeLazy.ActionOpts
---@class TelescopeLazy.Plugin ---@field path string ---@field name string ---@field readme string|nil ---@field url string ---@field lazy boolean ---@field dev boolean ---@field icon string
Commands
:Telescope lazy
Mappings
| Mappings | Action | | -------- | ----------------------------------------------------------------------------- | | <C-o> | Open selected plugin repository in browser | | <M-b> | Open selected plugin with file-browser | | <C-f> | Open selected plugin with find files | | <C-g> | Open selected plugin with live grep (will use egrepify if installed) | | <C-t> | Open selected plugin in a terminal | | <C-b> | Open lazy plugins picker, works only after having called first another action | | <C-r>f | Open lazy root with find files | | <C-r>g | Open lazy root with live grep (will use egrepify if installed) | | <C-c>d | Change the current working directory to the path of the selected plugin |
Acknowledgments
This extension is heavily inspired by telescope-packer.