Skip to content

Commit 40d6d81

Browse files
authored
feat(builtin): allow picking help pages and colorschemes not yet loaded by Lazy.nvim (#3295)
* feat(builtin.help_tags): show help pages for plugins not yet loaded by Lazy.nvim * feat(builtin.colorscheme): allow picking colors not yet loaded by Lazy.nvim
1 parent 927c10f commit 40d6d81

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lua/telescope/builtin/__internal.lua

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,17 @@ internal.help_tags = function(opts)
712712
end
713713

714714
local help_files = {}
715-
local all_files = vim.api.nvim_get_runtime_file("doc/*", true)
715+
716+
local rtp = vim.o.runtimepath
717+
-- extend the runtime path with all plugins not loaded by lazy.nvim
718+
local lazy = package.loaded["lazy.core.util"]
719+
if lazy and lazy.get_unloaded_rtp then
720+
local paths = lazy.get_unloaded_rtp ""
721+
if #paths > 0 then
722+
rtp = rtp .. "," .. table.concat(paths, ",")
723+
end
724+
end
725+
local all_files = vim.fn.globpath(rtp, "doc/*", 1, 1)
716726
for _, fullpath in ipairs(all_files) do
717727
local file = utils.path_tail(fullpath)
718728
if file == "tags" then
@@ -998,6 +1008,19 @@ internal.colorscheme = function(opts)
9981008
end, vim.fn.getcompletion("", "color"))
9991009
)
10001010

1011+
-- if lazy is available, extend the colors list with unloaded colorschemes
1012+
local lazy = package.loaded["lazy.core.util"]
1013+
if lazy and lazy.get_unloaded_rtp then
1014+
local paths = lazy.get_unloaded_rtp ""
1015+
local all_files = vim.fn.globpath(table.concat(paths, ","), "colors/*", 1, 1)
1016+
for _, f in ipairs(all_files) do
1017+
local color = vim.fn.fnamemodify(f, ":t:r")
1018+
if not vim.tbl_contains(colors, color) then
1019+
table.insert(colors, color)
1020+
end
1021+
end
1022+
end
1023+
10011024
if opts.ignore_builtins then
10021025
-- stylua: ignore
10031026
local builtins = {

0 commit comments

Comments
 (0)