Closed Mango0x45 closed 8 months ago
Update: Did a little testing, the issue seems to not be for all multi-byte characters? Doing ['ß'] = …
works just fine, as does ['ẞ'] = …
.
The default behavior is to duplicate the character on both sides, which seems to be what you are experiencing. Maybe try <C-v>[your funny quote character]
to see if nvim
is even registering it properly? The fact that other multi-byte characters work makes this a bit harder to debug...
Neovim does indeed register it properly.
Ok so it seems to also not work with the multi-byte ‘…
’ character. Could it be an issue with punctuation? Lol
I'm not sure; I don't have any special code to handle retrieving the character. Under the hood, things just use vim.fn.getcharstr
.
Well I’m playing around with :lua print(vim.fn.getcharstr())
and seem to have absolutely no problems with inputting other unicode characters. What is the relevant part of the code? Maybe I can poke around and see if I can get something to work.
I imagine the relevant code should be in input.lua
.
Ah here is a hint. At the very start of M.get_add()
in config.lua
I threw in:
for k, _ in pairs(M.get_opts().surrounds) do
print(k)
done
and I noticed that while all the other keys are being stored correctly (along with invalid_key_behavior
and some defaults), the U+2019
quote mark that I entered is showing up not as it usually does as a right-single-quote, but as <e2><80><fe>X<99>
. Looks like somewhere in the configuration unicode is not being properly handled.
Looks like the issue occurs somewhere in the call to M.translate_opts()
in M.merge_opts()
in config.lua
UPDATE: The issue is the call to vim.api.nvim_replace_termcodes()
Sorry for the delay; just writing to let you know that I really appreciate the PR and that it will be merged soon:tm:; I just want to figure out how to get your change autopublished to LuaRocks as well so it might take a little bit.
No worries! I just hope this gets merged soon™ because I use multibyte characters all the time :)
Checklist
:h nvim-surround
to see if there might be any relevant information there?Neovim Version
v0.9.4
Plugin Version
Tagged (Stable)
Minimal Configuration
Sample Buffer
(
*
is the cursor)Keystroke Sequence
Expected behavior
Actual behavior
Additional context
In case the GitHub font makes it hard to see, I am trying to create a custom surround pair using unicode curly quotes, which I have on my keyboard. I expect to be able to surround things with an opening curly quote and a closing curly quote, but the plugin completely ignores my configuration and just uses the closing quote on both ends. If I change the config to be
['X'] = { add = … } }
where X is any regular ASCII character, this issue stops.