diff --git a/doc/telescope.txt b/doc/telescope.txt index 9f3b339..f0f78ef 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -1112,6 +1112,8 @@ builtin.builtin({opts}) *telescope.builtin.builtin()* Options: ~ {include_extensions} (boolean) if true will show the pickers of the installed extensions (default: false) + {use_default_opts} (boolean) if the selected picker should use its + default options (default: false) builtin.resume({opts}) *telescope.builtin.resume()* 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