kylechui / nvim-surround

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

Curly braces surround doesn't work on xterm #178

Closed reach-satori closed 1 year ago

reach-satori commented 1 year ago

Checklist

Neovim Version


NVIM v0.9.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -ffile-prefix-map=/build/neovim-DC7YZQ/neovim-0.9.0~ubuntu1+git202211290022-f004812b3-333b5866f=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-DC7YZQ/neovim-0.9.0~ubuntu1+git202211290022-f004812b3-333b5866f/build/cmake.config -I/build/neovim-DC7YZQ/neovim-0.9.0~ubuntu1+git202211290022-f004812b3-333b5866f/src -I/build/neovim-DC7YZQ/neovim-0.9.0~ubuntu1+git202211290022-f004812b3-333b5866f/.deps/usr/include -I/usr/include -I/build/neovim-DC7YZQ/neovim-0.9.0~ubuntu1+git202211290022-f004812b3-333b5866f/build/src/nvim/auto -I/build/neovim-DC7YZQ/neovim-0.9.0~ubuntu1+git202211290022-f004812b3-333b5866f/build/include
Compiled by buildd@lcy02-amd64-096

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more inf

Plugin Version

Tagged (Stable)

Minimal Configuration

set runtimepath^=~/.vim
set rtp-=~/.vim/after
set rtp^=~/.vim/bundle/nvim-surround
set rtp+=~/.vim/bundle/nvim-surround/after
"set vif=NONE
"filetype plugin indent on
"syntax enable

lua << EOF
require("nvim-surround").setup {}
EOF

Sample Buffer

any

Keystroke Sequence

ysiw{

Expected behavior

{any}

Actual behavior

any

Additional context

Weird bug I came across. The curly brace surround (and only the curly brace surround, apparently) refuses to work under xterm. I tested xfce4-terminal and there it works with no problem whatever the config. Additionally, a very similar thing, also only with curly braces, happens when using vim-surround, except instead of just failing to work, it adds the following special-character gibberish: ۟}surrounded_word۟}

The bug happens identically on two computers I tested.

reach-satori commented 1 year ago

On further inspection, this seems to be a neovim bug: the weird bytes come through with just a plain call to getchar() as well, with curly braces.

kylechui commented 1 year ago

Glad you were able to find out the source of the issue, feel free to re-open this if there's anything that needs to be done on my end.

hinell commented 10 months ago

Link to neovim issue:

hinell commented 10 months ago

As a workaround, we can use aliases or setup new surroundings = { ... }, e.g.:

use({
    "kylechui/nvim-surround",
    tag = "*", -- Use for stability; omit to use `main` branch for the latest features
    config = function()
        local config     = require("nvim-surround.config");
        require("nvim-surround").setup({
            -- surrounds = {
            --  ["<S-{>"] = configDefault.surrounds["{"],
            --  ["<S-}>"] = configDefault.surrounds["}"]
        local configDefault = config.default_opts
            -- },
            aliases = {
                ["<S-{>"] = "{",
                ["<S-}>"] = "}"
            }
        })
    end
})