Skip to content

Commit

Permalink
feat: add deprecation warnings for updated options
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry committed Feb 6, 2025
1 parent c43a6c4 commit 1e3a490
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion lua/cyberdream/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,55 @@ local default_options = {
---@type Config
M.options = {}

-- TODO: Remove post v5.0.0
local function notify_deprecation(old_option, new_option)
vim.defer_fn(function()
vim.notify(
string.format("The '%s' is deprecated!\n\nUse '%s' instead.", old_option, new_option),
3,
{ title = "cyberdream.nvim" }
)
end, 1000)
end

-- TODO: Remove post v5.0.0
local function handle_theme_deprecation(options)
if not options.theme then
return options
end

notify_deprecation("theme table", "root table")

local theme_mappings = {
variant = true,
saturation = true,
colors = true,
highlights = true,
overrides = true,
}

for key in pairs(theme_mappings) do
if options.theme[key] then
options[key] = options.theme[key]
end
end

return options
end

---@param options Config|nil
function M.setup(options)
M.options = vim.tbl_deep_extend("force", {}, default_options, options or {})
options = options or {}
---@diagnostic disable: undefined-field
if options.borderless_telescope ~= nil then
notify_deprecation("borderless_telescope", "borderless_pickers")
options.borderless_pickers = options.borderless_telescope
end
---@diagnostic enable: undefined-field
options = handle_theme_deprecation(options)

--- TODO: Delete everything above post v5.0.0
M.options = vim.tbl_deep_extend("force", {}, default_options, options)
vim.g.cyberdream_opts = M.options
end

Expand Down

0 comments on commit 1e3a490

Please sign in to comment.