fix: builtin only have entries for extension functions (#1587)

* fix: `builtin` only have entries for extension functions

* fix: add check for underscore and explanation of which functions included
This commit is contained in:
Luke Kershaw
2021-12-19 17:55:50 +00:00
committed by GitHub
parent 5f37fbfa83
commit 9aaaa0c5f3
2 changed files with 11 additions and 5 deletions

View File

@@ -43,6 +43,9 @@ extensions.manager = setmetatable({}, {
---
--- Only the items in `exports` will be exposed on the resulting
--- module that users can access via require('telescope').extensions.foo
--- Also, any top-level key-value pairs in exports where the value is a function and the
--- key doesn't start with an underscore will be included when calling the `builtin` picker
--- with the `include_extensions` option enabled.
---
--- Other things in the module will not be accessible. This is the public API
--- for your extension. Consider not breaking it a lot :laugh:

View File

@@ -55,6 +55,8 @@ internal.builtin = function(opts)
title = "Telescope Pickers"
for ext, funcs in pairs(require("telescope").extensions) do
for func_name, func_obj in pairs(funcs) do
-- Only include exported functions whose name doesn't begin with an underscore
if type(func_obj) == "function" and string.sub(func_name, 0, 1) ~= "_" then
local debug_info = debug.getinfo(func_obj)
table.insert(objs, {
filename = string.sub(debug_info.source, 2),
@@ -63,6 +65,7 @@ internal.builtin = function(opts)
end
end
end
end
pickers.new(opts, {
prompt_title = title,