summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorLuke Kershaw <35707277+l-kershaw@users.noreply.github.com>2021-07-03 22:31:45 +0100
committerGitHub <noreply@github.com>2021-07-03 23:31:45 +0200
commita5608b9026b67269b2ef9a34d0cbaa3e477aca0c (patch)
tree2123149e7c6d866331e88526c1dd1d3d2d82694a /lua
parentbdd0df73a6ee424f9c77624218b4fba1e42e468c (diff)
feat: option to `include_extensions` in `builtin` picker (#953)
- add option `include_extensions` which defaults to `false` - if `include_extensions` is `true` then add functions from extensions to results - update `actions.run_builtin` to check if extension function provided
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/actions/init.lua13
-rw-r--r--lua/telescope/builtin/internal.lua18
2 files changed, 28 insertions, 3 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua
index af4c1c8..bf45bb3 100644
--- a/lua/telescope/actions/init.lua
+++ b/lua/telescope/actions/init.lua
@@ -332,8 +332,17 @@ end
actions.run_builtin = function(prompt_bufnr)
local entry = action_state.get_selected_entry(prompt_bufnr)
-actions._close(prompt_bufnr, true)
- require('telescope.builtin')[entry.text]()
+ actions._close(prompt_bufnr, true)
+ if string.match(entry.text," : ") then
+ -- Call appropriate function from extensions
+ local split_string = vim.split(entry.text," : ")
+ local ext = split_string[1]
+ local func = split_string[2]
+ require('telescope').extensions[ext][func]()
+ else
+ -- Call appropriate telescope builtin
+ require('telescope.builtin')[entry.text]()
+ end
end
actions.insert_symbol = function(prompt_bufnr)
diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua
index 6235ddf..d53776d 100644
--- a/lua/telescope/builtin/internal.lua
+++ b/lua/telescope/builtin/internal.lua
@@ -21,6 +21,7 @@ local internal = {}
internal.builtin = function(opts)
opts.hide_filename = utils.get_default(opts.hide_filename, true)
opts.ignore_filename = utils.get_default(opts.ignore_filename, true)
+ opts.include_extensions = utils.get_default(opts.include_extensions, false)
local objs = {}
@@ -32,8 +33,23 @@ internal.builtin = function(opts)
})
end
+ local title = 'Telescope Builtin'
+
+ if opts.include_extensions then
+ 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),
+ })
+ end
+ end
+ end
+
pickers.new(opts, {
- prompt_title = 'Telescope Builtin',
+ prompt_title = title,
finder = finders.new_table {
results = objs,
entry_maker = function(entry)