Closed Diomendius closed 2 years ago
Hah the fail message was intentional after #59, as seen in #75. I think there's a config option to set that disable the message but I'm forgetting at the moment.
@NoahTheDuke This message (caused by the default function attached to invalid_key_behavior
) is definitely intentional:
Error: Invalid character! Configure this message in require("nvim-surround").setup()
But this message definitely isn't:
E5108: Error executing lua: …/nvim-surround/lua/nvim-surround/init.lua:49: attempt to index local 'delimiters' (a nil value)
This PR doesn't do anything about the former; the message still prints by default and it's still configurable. The Lua error only occurs when using the insert mode surround feature; yslw
from normal mode only prints the "Invalid character!" message, for instance.
Ope, my apologies, I misunderstood your issue! Good catch.
Firstly, this fixes the insert mode surround feature causing a
…/nvim-surround/lua/nvim-surround/init.lua:49: attempt to index local 'delimiters' (a nil value)
Lua error when pressing a key that doesn't map to any delimiter.Secondly, this makes the indentation of the inner line in multi-line mode (
<c-g>S
by default) consistent with native auto-indent. Before this patch, ifshiftwidth
was0
the inner line would have the same indent as the lines next to it.This plugin would also falsely assume all tabs have a width equal to
shiftwidth
. Tab width is always defined bytabstop
(unlessvartabstop
is set) andshiftwidth
doesn't even have to be a multiple oftabstop
, regardless of whetherexpandtab
is set. Any configuration withnoexpandtab
and ashiftwidth
that isn't identical totabstop
(or0
, which has the same meaning) or at least a multiple oftabstop
is, of course, awful, but that doesn't meannvim-surround
can't do what native indent behaviour does.vartabstop
is even more cursed, but if there's anyone who actually uses both it and this plugin I'm sure they'll be pleased to see this fix. :stuck_out_tongue: