From 1d46f84163bbe6b5b12045aff36207b2d78b8da1 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 13 May 2024 20:03:57 -0700 Subject: [PATCH] Remove options --- lua/argonaut/config.lua | 8 +++----- lua/argonaut/types.lua | 41 ++++++++++++++++------------------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/lua/argonaut/config.lua b/lua/argonaut/config.lua index 928e00d..20ea66a 100644 --- a/lua/argonaut/config.lua +++ b/lua/argonaut/config.lua @@ -7,8 +7,6 @@ local opt_curr = { comma_prefix = false, comma_prefix_indent = false, line_max = 32, - line_prefix = '', - trim_inner_spaces = true, }, go = { comma_last = true, @@ -39,9 +37,9 @@ local function get() for param_name, param_value in pairs(opt_curr.default) do file_opt[param_name] = param_value if file_opt_curr then - param_value = file_opt_curr[param_name] - if param_value ~= nil then - file_opt[param_name] = param_value + local param_value_curr = file_opt_curr[param_name] + if param_value_curr ~= nil then + file_opt[param_name] = param_value_curr end end end diff --git a/lua/argonaut/types.lua b/lua/argonaut/types.lua index de2a5db..bd2ab27 100644 --- a/lua/argonaut/types.lua +++ b/lua/argonaut/types.lua @@ -296,31 +296,25 @@ function Param:trim() self:slice(1, #self.text - #self.text:match('%s*$')) self:slice(1 + #self.text:match('^%s*'), #self.text) - if self.text:match('^' .. self.opt.line_prefix) then - self:slice(1 + #self.opt.line_prefix, #self.text) - end + local text = '' + local literals = {} + local offset = self.offset - if self.opt.trim_inner_spaces then - local text = '' - local literals = {} - local offset = self.offset + for i = 1, #self.text do + local char = self.text:sub(i, i) + local literal = self.literals[i] - for i = 1, #self.text do - local char = self.text:sub(i, i) - local literal = self.literals[i] - - if literal or not char:match('%s') or not text:match('%s$') then - text = text .. char - table.insert(literals, literal) - elseif offset and offset >= i then - self.offset = math.max(1, self.offset - 1) - end + if literal or not char:match('%s') or not text:match('%s$') then + text = text .. char + table.insert(literals, literal) + elseif offset and offset >= i then + self.offset = math.max(1, self.offset - 1) end - - self.text = text - self.literals = literals end + self.text = text + self.literals = literals + return #self.text > 0 end @@ -391,9 +385,9 @@ function ParamList:parse() for col = start_col, stop_col do self:update(line:sub(col, col), brace_stack, Cursor.new(row, col)) end - - self:flush() end + + self:flush() end -- @@ -535,7 +529,6 @@ function WrapContext:wrap() local is_last_param = i == #self.params.parsed if self.opt.comma_prefix then - builder:update(self.opt.line_prefix) if not is_first_param then builder:update(', ') elseif self.opt.comma_prefix_indent and not is_last_param then @@ -543,7 +536,6 @@ function WrapContext:wrap() end cursor = self:update_builder_param(builder, param) or cursor else - builder:update(self.opt.line_prefix) cursor = self:update_builder_param(builder, param) or cursor if not is_last_param or self.opt.comma_last then builder:update(',') @@ -562,7 +554,6 @@ function WrapContext:wrap() end if self.opt.brace_last_wrap then - builder:update(self.opt.line_prefix) builder:update(self.suffix) builder:flush() end