feat: add option use_default_opts to builtin.builtin (#1996)
This commit is contained in:
committed by
Simon Hauser
parent
15f6a0bb08
commit
6703c957e7
@@ -1112,6 +1112,8 @@ builtin.builtin({opts}) *telescope.builtin.builtin()*
|
|||||||
Options: ~
|
Options: ~
|
||||||
{include_extensions} (boolean) if true will show the pickers of the
|
{include_extensions} (boolean) if true will show the pickers of the
|
||||||
installed extensions (default: false)
|
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()*
|
builtin.resume({opts}) *telescope.builtin.resume()*
|
||||||
|
|||||||
@@ -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
|
--- Lists all of the community maintained pickers built into Telescope
|
||||||
---@param opts table: options to pass to the picker
|
---@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 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
|
builtin.builtin = require_on_exported_call("telescope.builtin.internal").builtin
|
||||||
|
|
||||||
--- Opens the previous picker in the identical state (incl. multi selections)
|
--- Opens the previous picker in the identical state (incl. multi selections)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ local internal = {}
|
|||||||
|
|
||||||
internal.builtin = function(opts)
|
internal.builtin = function(opts)
|
||||||
opts.include_extensions = vim.F.if_nil(opts.include_extensions, false)
|
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 = {}
|
local objs = {}
|
||||||
|
|
||||||
@@ -91,15 +92,20 @@ internal.builtin = function(opts)
|
|||||||
-- we do this to avoid any surprises
|
-- we do this to avoid any surprises
|
||||||
opts.include_extensions = nil
|
opts.include_extensions = nil
|
||||||
|
|
||||||
|
local picker_opts
|
||||||
|
if not opts.use_default_opts then
|
||||||
|
picker_opts = opts
|
||||||
|
end
|
||||||
|
|
||||||
if string.match(selection.text, " : ") then
|
if string.match(selection.text, " : ") then
|
||||||
-- Call appropriate function from extensions
|
-- Call appropriate function from extensions
|
||||||
local split_string = vim.split(selection.text, " : ")
|
local split_string = vim.split(selection.text, " : ")
|
||||||
local ext = split_string[1]
|
local ext = split_string[1]
|
||||||
local func = split_string[2]
|
local func = split_string[2]
|
||||||
require("telescope").extensions[ext][func](opts)
|
require("telescope").extensions[ext][func](picker_opts)
|
||||||
else
|
else
|
||||||
-- Call appropriate telescope builtin
|
-- Call appropriate telescope builtin
|
||||||
require("telescope.builtin")[selection.text](opts)
|
require("telescope.builtin")[selection.text](picker_opts)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user