Skip to content

Commit

Permalink
chore: Add deprecation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylechui committed Aug 13, 2022
1 parent f5040b5 commit 28aa65e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lua/nvim-surround/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,17 @@ M.get_selection = function(args)
return require("nvim-surround.textobjects").get_selection(args.motion)
elseif args.node then
return require("nvim-surround.treesitter").get_selection(args.node)
---[=[ DEPRECATION WARNING
---@diagnostic disable-next-line: undefined-field
elseif args.textobject then
local textobject_warning = {
"The `textobject` key has been deprecated in favor of the `motion` key.",
"Please pre-pend text-object keys with 'a'. See :h nvim-surround.config.get_selection() for details",
}
vim.notify_once(table.concat(textobject_warning, "\n"), vim.log.levels.ERROR)
--]=]
else
vim.notify("Invalid key provided for `:h nvim-surround.config.get_selection()`.", vim.log.levels.ERROR)
end
end

Expand Down Expand Up @@ -386,7 +397,7 @@ end
---@param opts options? The user-provided options.
---@return options? @The translated options.
M.translate_opts = function(opts)
---[=[ SOFT DEPRECATION WARNINGS
---[=[ DEPRECATION WARNINGS
---@diagnostic disable-next-line: undefined-field
if opts and opts.highlight_motion then
local highlight_warning = {
Expand All @@ -397,19 +408,19 @@ M.translate_opts = function(opts)
end
---@diagnostic disable-next-line: undefined-field
if opts and opts.delimiters then
local highlight_warning = {
local delimiter_warning = {
"The `delimiters` table has been renamed to `surrounds`.",
"See :h nvim-surround.config.surrounds for details",
}
vim.notify_once(table.concat(highlight_warning, "\n"), vim.log.levels.ERROR)
vim.notify_once(table.concat(delimiter_warning, "\n"), vim.log.levels.ERROR)
end
--]=]

if not (opts and opts.surrounds) then
return opts
end
for char, val in pairs(opts.surrounds) do
---[=[ SOFT DEPRECATION WARNINGS
---[=[ DEPRECATION WARNINGS
if char == "pairs" or char == "separators" then
local delimiter_warning = {
"The `pairs` and `separators` tables have been deprecated; configuration for surrounds",
Expand Down

0 comments on commit 28aa65e

Please sign in to comment.