Closed bew closed 1 year ago
All of this should be able to be customized via the indent_lines
configuration key, as well as customizing the delete
key for surrounds.
See the following:
:h nvim-surround.config.indent_lines
(probably copy the function there and change it to strict inequality):h nvim-surround.config.delete
(change the Lua pattern to match leading and trailing whitespace as well); also see the default configurationIndeed I managed to stop reindent with:
local surround_utils = require"nvim-surround.config"
require"nvim-surround".setup {
-- ...
indent_lines = function(start_row, end_row)
if start_row ~= end_row then
surround_utils.default_opts.indent_lines(start_row, end_row)
end
end,
}
:+1:
For {
removing spaces, I also found how to customize the delete pattern!
Would you accept a PR to change the current default to remove as much whitespace as possible instead of just 1 ?
I would say probably not, as there are probably quite a few people that are used to the current default behavior. Whether or not your implementation is "more correct" is also debatable.
Hmm true, maybe add something like it in a wiki or documentation?
Here is my implementation if you want to take a look: https://github.com/bew/dotfiles/commit/b7dc4ee3ffdea87c9d10dbeae3a0f69dbdf354e3
This should be implemented in the latest commit/version.
Checklist
:h nvim-surround
to see if there might be any relevant information there?Is your feature request related to a problem? Please describe.
Happened today, in a Lua file, I pasted something and wanted to change it a bit before integrating it somewhere else.
I go on the pasted text and do
ds'
to remove the quotes, and I surprisingly got:It seems to only happen when I delete the quotes, not when I add or change them.
Describe the solution you'd like
I want to delete surrounds without changing indentation.
In a more general way, I think that surround changes that only impact the current line shouldn't change the indentation. So:
Then do
ds'
on thefoobar
line, should give:Because the surround only impacted the line with
foobar
BUT:
Then do
ds}
on thefoobar
line, should auto-indent and give: