From 9d241775a9eb49a3fece4b4333b11dbc5fd804ba Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 2 May 2024 21:17:58 -0700 Subject: [PATCH] Update line prefix behavior --- lua/argonaut/config.lua | 3 +-- lua/argonaut/types.lua | 19 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lua/argonaut/config.lua b/lua/argonaut/config.lua index a66eab1..928e00d 100644 --- a/lua/argonaut/config.lua +++ b/lua/argonaut/config.lua @@ -14,8 +14,7 @@ local opt_curr = { comma_last = true, }, vim = { - brace_last_wrap = false, - line_prefix = '\\ ', + line_prefix = '\\', } } diff --git a/lua/argonaut/types.lua b/lua/argonaut/types.lua index 48f73ba..b802269 100644 --- a/lua/argonaut/types.lua +++ b/lua/argonaut/types.lua @@ -280,6 +280,10 @@ function Param:trim() self:slice(1, #self.text - #self.text:match('%s*$')) self:slice(1 + #self.text:match('^%s*'), #self.text) + if #self.opt.line_prefix > 0 and self.text:match('^' .. self.opt.line_prefix) then + self:slice(1 + #self.opt.line_prefix, #self.text) + end + if self.opt.trim_inner_spaces then local text = '' local literals = {} @@ -366,9 +370,9 @@ function ParamList:parse() for col = start_col, stop_col do self:update(line:sub(col, col), brace_stack, Cursor.new(row, col)) end - end - self:flush() + self:flush() + end end -- @@ -487,20 +491,14 @@ function WrapContext:parse() end function WrapContext:update_builder_param(builder, param) - local text = param.text - if #self.opt.line_prefix > 0 then - text = param.text:match('^%s*[' .. self.opt.line_prefix .. ']?%s*(.*)') - end - local cursor = nil if param:is_active() then - local offset_delta = #param.text - #text cursor = builder:get_offset() cursor.row = cursor.row + self.range.start.row - cursor.col = cursor.col + param.offset - offset_delta + cursor.col = cursor.col + param.offset end - builder:update(text) + builder:update(param.text) return cursor end @@ -543,6 +541,7 @@ function WrapContext:wrap() end if self.opt.brace_last_wrap then + builder:update(self.opt.line_prefix) builder:update(self.suffix) builder:flush() end