Skip to content

Commit 895e8d9

Browse files
committed
feat(telescope): add dynamic user command for Telescope picker
Signed-off-by: Guennadi Maximov C <g.maxc.fox@protonmail.com>
1 parent d8ac8c4 commit 895e8d9

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
local Main = require('telescope._extensions.projects.main')
22
local Telescope = require('telescope')
33

4-
return Telescope.register_extension({
4+
---@class TelescopeProjects
5+
---@field exports { projects: fun(opts?: table) }
6+
---@field projects fun(opts?: table)
7+
---@field setup fun(opts: table)
8+
9+
---@type TelescopeProjects
10+
local M = Telescope.register_extension({
511
setup = Main.setup,
612
exports = { projects = Main.projects },
713
projects = Main.projects,
814
})
915

16+
return M
17+
1018
-- vim:ts=4:sts=4:sw=4:et:ai:si:sta:noci:nopi:

plugin/project.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,20 @@ end, {
9797
end,
9898
})
9999

100+
---Add `Fzf-Lua` command ONLY if it is installed
100101
if require('project.utils.util').mod_exists('fzf-lua') then
101102
vim.api.nvim_create_user_command('ProjectFzf', require('project').run_fzf_lua, {
102-
desc = 'Run project.nvim through Fzf-Lua (assuming you have it enabled)',
103+
desc = 'Run project.nvim through Fzf-Lua (assuming you have it installed)',
103104
})
104105
end
106+
107+
---Add `Telescope` shortcut ONLY if it is installed
108+
if require('project.utils.util').mod_exists('telescope') then
109+
vim.api.nvim_create_user_command(
110+
'ProjectTelescope',
111+
require('telescope._extensions.projects').projects,
112+
{
113+
desc = 'Telescope shortcut for project.nvim picker',
114+
}
115+
)
116+
end

0 commit comments

Comments
 (0)