Skip to content

Commit

Permalink
fix: builtin only have entries for extension functions (nvim-telesc…
Browse files Browse the repository at this point in the history
…ope#1587)

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

* fix: add check for underscore and explanation of which functions included
  • Loading branch information
l-kershaw authored Dec 19, 2021
1 parent 5f37fbf commit 9aaaa0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lua/telescope/_extensions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 8 additions & 5 deletions lua/telescope/builtin/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ 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
local debug_info = debug.getinfo(func_obj)
table.insert(objs, {
filename = string.sub(debug_info.source, 2),
text = string.format("%s : %s", ext, func_name),
})
-- 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),
text = string.format("%s : %s", ext, func_name),
})
end
end
end
end
Expand Down

0 comments on commit 9aaaa0c

Please sign in to comment.