fix: hide deprecation notice when option not used (#26)

This commit is contained in:
Steven Arcangeli 2022-03-17 10:01:53 -07:00
parent 01afd7b01f
commit 96552c9199
2 changed files with 15 additions and 17 deletions

View File

@ -132,11 +132,24 @@ M.update = function(opts)
)
end
if newconf.select.telescope and newconf.select.telescope.theme then
if
newconf.select.telescope
and newconf.select.telescope.theme
and vim.tbl_count(newconf.select.telescope) == 1
then
vim.notify(
"Deprecated: dressing.select.telescope.theme is deprecated. Pass in telescope options directly (:help dressing)",
vim.log.levels.WARN
)
local theme = newconf.select.telescope.theme
local ttype = type(theme)
if ttype == "string" then
newconf.select.telescope = require("telescope.themes")[string.format("get_%s", theme)]()
elseif ttype == "function" then
newconf.select.telescope = theme({})
else
newconf.select.telescope = theme
end
end
for k, v in pairs(newconf) do

View File

@ -23,24 +23,9 @@ M.select = function(config, items, opts, on_choice)
local picker_opts = config
-- Default to the dropdown theme if no options supplied
if picker_opts == nil then
-- Default to the dropdown theme if no options supplied
picker_opts = themes.get_dropdown()
elseif config.theme then
-- Backwards compatibility for the `theme` option
local theme
local ttype = type(config.theme)
if ttype == "string" then
theme = themes[string.format("get_%s", config.theme)]
elseif ttype == "function" then
theme = config.theme
else
theme = function(s)
return vim.tbl_extend("keep", s, config.theme or {})
end
end
picker_opts = vim.tbl_extend("keep", config, theme({}))
end
pickers.new(picker_opts, {