Skip to content

Commit

Permalink
fix: hide deprecation notice when option not used (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Mar 17, 2022
1 parent 01afd7b commit 96552c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
15 changes: 14 additions & 1 deletion lua/dressing/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 1 addition & 16 deletions lua/dressing/select/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 96552c9

Please sign in to comment.