From 7247ec5a70cc153a32b7cee288b9640597572e7b Mon Sep 17 00:00:00 2001 From: Artem Medeu Date: Sun, 13 Aug 2023 19:18:29 +0600 Subject: [PATCH] slurp backwards does not require indentation also (put extra space) --- lua/nvim-paredit/api/slurping.lua | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lua/nvim-paredit/api/slurping.lua b/lua/nvim-paredit/api/slurping.lua index 9482543..5cdf3c3 100644 --- a/lua/nvim-paredit/api/slurping.lua +++ b/lua/nvim-paredit/api/slurping.lua @@ -71,24 +71,32 @@ local function slurp(opts) offset = string.len(left_or_right_edge.text) end + local token + if opts.reversed then + token = " " + else + token = "" + end -- stylua: ignore vim.api.nvim_buf_set_text( buf, left_or_right_edge.range[1], left_or_right_edge.range[2] + offset, left_or_right_edge.range[3], left_or_right_edge.range[4] + offset, - {} + {token} ) - indentation.handle_indentation({ - type = "slurp", - from = left_or_right_edge.range, - to = { row, col, row, col }, - child = sibling, - parent = form, - - indent_behaviour = opts.indent_behaviour or config.config.indent_behaviour, - lang = lang, - }) + if not opts.reversed then + indentation.handle_indentation({ + type = "slurp", + from = left_or_right_edge.range, + to = { row, col, row, col }, + child = sibling, + parent = form, + reversed = opts.reversed, + indent_behaviour = opts.indent_behaviour or config.config.indent_behaviour, + lang = lang, + }) + end local cursor_behaviour = opts.cursor_behaviour or config.config.cursor_behaviour if cursor_behaviour == "follow" then