kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.18k stars 62 forks source link

Breaking Changes: Following `main` #77

Open kylechui opened 2 years ago

kylechui commented 2 years ago

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!

kylechui commented 2 years ago

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,
    }
})
kylechui commented 2 years ago

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).

kylechui commented 2 years ago

As of #92, the default keymaps for normal-mode surrounds have had their names changed:

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.

kylechui commented 2 years ago

With the introduction of #113, quite a few breaking changes have been introduced.

Configuration

Please see the default configuration and :h nvim-surround.configuration for details/examples.

Behavior

    Old text                    Command         New text
    some_text                   ysiw|           |some_text|
    |some_text|                 ds|             some_text
    |some_text|                 cs|b            (some_text)
kylechui commented 2 years ago

With the introduction of #136, some configuration options have been renamed to better reflect their actual purpose:

-- Old configuration
require("nvim-surround.config").get_selection({
    textobject = ")",
})
-- New configuration
require("nvim-surround.config").get_selection({
    motion = "a)",
})
kylechui commented 1 year ago

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.

kylechui commented 1 year ago

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