kylechui / nvim-surround

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

normal_cur_line doesn't work well when I set normal_line=false #160

Closed Fau818 closed 1 year ago

Fau818 commented 1 year ago

Checklist

To reproduce

local config = {
    keymaps = {
        insert = false,
        insert_line = false,
        normal = "s",
        normal_cur = "ss",
        normal_line = false,
        normal_cur_line = "S",
        visual = "s",
        visual_line = "S",
        delete = "ds",
        change = "cs",
    },
}

If I use the above setting, an error will occur when I type S in normal mode. I guess if normal_line was be disabled, the normal_cur_line couldn't work well.

Now, I just use normal_line = "SSSSSSSSSSSSSSS" to avoid that error, but I hope it can be fixed.


By the way, because of the highlight feature, this plugin performed very nice for me, but it couldn't keep the highlight selection area if I try to surround a word in visual mode. Could it keep highlight area in visual mode?

Expected behavior

No response

Actual behavior

No response

Additional context

No response

kylechui commented 1 year ago

As of right now, the implementation for normal_cur_line is dependent on the implementation for normal_line; I'll see if I can separate the two in a later update. I don't quite understand what you mean by "keep" highlight area for visual mode here. nvim-surround does not generate any highlights on its own for visual surrounds, as it just uses the default highlight for when you are visually selecting some block of text.

Fau818 commented 1 year ago

https://user-images.githubusercontent.com/75115028/197084043-cbd2566d-af11-4ef0-a2bc-981dd8251677.mov

Here is a video to show that.

When I use nvim-surround to surround a text in normal mode, it could highlight the area until I type the surrounding char. Until now everything is fine.

But when I surround a text in visual mode, it removes the original highlight area. I like it could keep the original highlight area selected by me.

kylechui commented 1 year ago

Sorry for the late response, but that is quite puzzling. It works on my end and I can't think of a reason that it would be clearing the highlights there; it should just use the visual selection that you provided. Are you using a tagged version of the plugin? If so, I would say to try out the "nightly" version on main and see if that fixes things.

kylechui commented 1 year ago

Hi @Fau818 can you try updating to the latest untagged version? Feel free to re-open this if it doesn't work.

Fau818 commented 1 year ago

Thank you very much! It's working great!