From 40d6d81b1d2e527bbe5d3fe5e6896de745bc1c84 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Mon, 16 Sep 2024 12:27:51 -0400 Subject: [PATCH] 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 --- lua/telescope/builtin/__internal.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/telescope/builtin/__internal.lua b/lua/telescope/builtin/__internal.lua index 4c330b4..3960c7b 100644 --- a/lua/telescope/builtin/__internal.lua +++ b/lua/telescope/builtin/__internal.lua @@ -712,7 +712,17 @@ internal.help_tags = function(opts) end local help_files = {} - local all_files = vim.api.nvim_get_runtime_file("doc/*", true) + + local rtp = vim.o.runtimepath + -- extend the runtime path with all plugins not loaded by lazy.nvim + local lazy = package.loaded["lazy.core.util"] + if lazy and lazy.get_unloaded_rtp then + local paths = lazy.get_unloaded_rtp "" + if #paths > 0 then + rtp = rtp .. "," .. table.concat(paths, ",") + end + end + local all_files = vim.fn.globpath(rtp, "doc/*", 1, 1) for _, fullpath in ipairs(all_files) do local file = utils.path_tail(fullpath) if file == "tags" then @@ -998,6 +1008,19 @@ internal.colorscheme = function(opts) end, vim.fn.getcompletion("", "color")) ) + -- if lazy is available, extend the colors list with unloaded colorschemes + local lazy = package.loaded["lazy.core.util"] + if lazy and lazy.get_unloaded_rtp then + local paths = lazy.get_unloaded_rtp "" + local all_files = vim.fn.globpath(table.concat(paths, ","), "colors/*", 1, 1) + for _, f in ipairs(all_files) do + local color = vim.fn.fnamemodify(f, ":t:r") + if not vim.tbl_contains(colors, color) then + table.insert(colors, color) + end + end + end + if opts.ignore_builtins then -- stylua: ignore local builtins = {