kylechui / nvim-surround

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

Finding and deleting surrounds is broken #344

Closed Mango0x45 closed 2 months ago

Mango0x45 commented 2 months ago

Checklist

Neovim Version

NVIM v0.10.0

Plugin Version

Tagged (Stable)

Minimal Configuration

require('nvim-surround').setup {
    surrounds = {
        ['“'] = {
            add = { '„', '“' },
            find = '„[^„“]*“',
            delete = '^(„)().-(“)()$',
        },
    }
}

Sample Buffer

Hallo „Welt“

Keystroke Sequence

vi“U

Expected behavior

Hallo „WELT“

Actual behavior

Nothing happens. The vi“ never visually selects any text

Additional context

The regex pattern I provide certainly isn’t wrong. The following test works just fine:

local s = 'Hallo „Welt“'
print(s:match '„[^„“]*“') -- '„Welt“'

This might also be an issue to do with multibyte surrounds. I do not know though, and I haven’t had time to test.

Along with finding selections via motions, deletion also does not work at all.

kylechui commented 2 months ago

The lack of being able to do vi[quote char] is intended behavior, since Vim does not natively support that as a quote textobject (see :h v_iquote). You would need to use something like targets.vim/mini.ai/nvim-nstextobjects to get the behavior I think you're looking for. I'm not able to reproduce the bug with being unable to delete the quotes either; please try updating the plugin and see if that helps.

Mango0x45 commented 2 months ago

I'm not able to reproduce the bug with being unable to delete the quotes either; please try updating the plugin and see if that helps.

Weirdly it works on my work laptop, but I’m unable to test rn on my personal one. I suppose I was probably doing something wrong then.

The lack of being able to do vi[quote char] is intended behavior, since Vim does not natively support that as a quote textobject (see :h v_iquote). You would need to use something like targets.vim/mini.ai/nvim-nstextobjects to get the behavior I think you're looking for.

Ah I see. I was confused by the purpose of find in the config (thinking it was for exactly this), but re-reading the documentation has cleared this up for me.

I’ll close this issue now

kylechui commented 2 months ago

If the issue persists and you're able to reproduce it, please re-open this issue!