diff options
| author | Bjarki Baldursson Harksen <62466569+mrbjarksen@users.noreply.github.com> | 2022-06-12 11:08:30 +0000 |
|---|---|---|
| committer | Simon Hauser <simon.hauser@helsinki-systems.de> | 2022-06-30 14:01:50 +0200 |
| commit | 6703c957e7d9a5dc5f91ceb59326ab7e05274642 (patch) | |
| tree | 95ed4500e032597cbd3d484a503fc28e32fa78da /lua | |
| parent | 15f6a0bb08f934bc999c8b5e54fb574f5889558f (diff) | |
feat: add option `use_default_opts` to `builtin.builtin` (#1996)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/builtin/init.lua | 1 | ||||
| -rw-r--r-- | lua/telescope/builtin/internal.lua | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 9fa6826..ea871aa 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -205,6 +205,7 @@ builtin.git_stash = require_on_exported_call("telescope.builtin.git").stash --- Lists all of the community maintained pickers built into Telescope ---@param opts table: options to pass to the picker ---@field include_extensions boolean: if true will show the pickers of the installed extensions (default: false) +---@field use_default_opts boolean: if the selected picker should use its default options (default: false) builtin.builtin = require_on_exported_call("telescope.builtin.internal").builtin --- Opens the previous picker in the identical state (incl. multi selections) diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua index 8a41500..e4a5704 100644 --- a/lua/telescope/builtin/internal.lua +++ b/lua/telescope/builtin/internal.lua @@ -33,6 +33,7 @@ local internal = {} internal.builtin = function(opts) opts.include_extensions = vim.F.if_nil(opts.include_extensions, false) + opts.use_default_opts = vim.F.if_nil(opts.use_default_opts, false) local objs = {} @@ -91,15 +92,20 @@ internal.builtin = function(opts) -- we do this to avoid any surprises opts.include_extensions = nil + local picker_opts + if not opts.use_default_opts then + picker_opts = opts + end + if string.match(selection.text, " : ") then -- Call appropriate function from extensions local split_string = vim.split(selection.text, " : ") local ext = split_string[1] local func = split_string[2] - require("telescope").extensions[ext][func](opts) + require("telescope").extensions[ext][func](picker_opts) else -- Call appropriate telescope builtin - require("telescope.builtin")[selection.text](opts) + require("telescope.builtin")[selection.text](picker_opts) end end) return true |
