nvim-surround
nvim-surround copied to clipboard
Breaking Changes: Following `main`
I will be using this thread as the main place to notify users of breaking changes, so subscribe to this issue to stay up to date about changes that may affect your configuration. Furthermore, breaking commits will be flagged with a !, e.g. refactor!: ..., so if you notice one of those commit messages when updating, refer to this issue.
Thanks to everybody for using this plugin, and sorry for the inconvenience!
As of #66, the default behavior for handling invalid keys into the delimiter table is no longer to surround using the key on the left and right hand side, but rather to throw an error message. For more information, see :h nvim-surround.delimiters.invalid_key_behavior. To re-enable the old default behavior, use the following in your configuration:
require("nvim-surround").setup({
delimiters = {
invalid_key_behavior = function(char)
return { char, char }
end,
}
})
Forgot to mention this (sorry!), but also as of #66, the provided function utils.get_input() has been deprecated in favor of using the built-in vim.fn.input(). The documentation will be patched shortly, see the default config for more details (in particular, the leading comment about keyboard interrupts).
As of #92, the default keymaps for normal-mode surrounds have had their names changed:
insert→normalinsert_line→normal_cur
The new naming scheme reflects that insert means insert-mode mapping, while normal means normal-mode mapping. Furthermore, the _cur suffix means that the mapping operates on the current line, while the _line suffix means that the mapping will place the delimiter pair on new lines. See :h nvim-surround.keymaps for more details.
With the introduction of #113, quite a few breaking changes have been introduced.
Configuration
- The
delimiterstable has been renamed tosurrounds pairsandseparatorshave been deprecated; store surround keys directly insurrounds- The surround values have also been changed, see
:h nvim-surround.configurationfor details
- The surround values have also been changed, see
highlight_motionhas been renamed tohighlight- An argument table is no longer passed into the function used to create the surround by default (see #29, I doubt anybody made use of this)
Please see the default configuration and :h nvim-surround.configuration for details/examples.
Behavior
- The default
invalid_key_behaviornow takes the input character and adds/modifies it on the left/right. For example, by default|is not configured as a surround key:
Old text Command New text
some_text ysiw| |some_text|
|some_text| ds| some_text
|some_text| cs|b (some_text)
- The behavior for modifying deleting/changing open pairs is slightly different, see this commit.
With the introduction of #136, some configuration options have been renamed to better reflect their actual purpose:
highlight_motion→highlightNvimSurroundHighlightTextObject→NvimSurroundHighlight- The
textobjectkey forrequire("nvim-surround.config").get_selection()has been replaced by themotionkey. This allows for better compatibility withtargets.vimand similar plugins that define their own text-objects. All existingtextobjectkeys just need to be pre-pended withato represent the correct motion, e.g.
-- Old configuration
require("nvim-surround.config").get_selection({
textobject = ")",
})
-- New configuration
require("nvim-surround.config").get_selection({
motion = "a)",
})
As of 87839e1, "smart" quotes have now been removed from nvim-surround. Now, modifying quotes will exclusively modify the immediate surrounding pair, instead of trying to compute some "quote balancing" to figure out which pair to delete. For example, running ds" on the following text with the cursor at *:
-- Original text
local str = "This string has "invalid quo*tes" in it!"
-- Old behavior (jumps to the second pair and deletes)
local str = "This string has "invalid quotes in it!
-- New behavior (doesn't jump, deleting the immediate surrounding pair)
local str = "This string has invalid quotes in it!"
Please see #153 for the rationale behind this decision.
Note: If your configuration does not define invalid_key_behavior, this has no effect on you.
As of ebdd22d, custom invalid_key_behavior functions will now parse control and multi-byte characters, e.g. if your setup contains:
require("nvim-surround").setup({
surrounds = {
invalid_key_behavior = {
add = function(char) -- This function now accepts control chars
return { { char }, { char } }
end
}
-- Note that there is no surround for <CR>
}
}
Then ysiw<CR> will surround words with a carriage return literal, e.g.
word
-- ysiw<CR>
^Mword^M