1

Remove options

This commit is contained in:
Alex Yatskov 2024-05-13 20:03:57 -07:00
parent 2b2d831837
commit 1d46f84163
2 changed files with 19 additions and 30 deletions

View File

@ -7,8 +7,6 @@ local opt_curr = {
comma_prefix = false, comma_prefix = false,
comma_prefix_indent = false, comma_prefix_indent = false,
line_max = 32, line_max = 32,
line_prefix = '',
trim_inner_spaces = true,
}, },
go = { go = {
comma_last = true, comma_last = true,
@ -39,9 +37,9 @@ local function get()
for param_name, param_value in pairs(opt_curr.default) do for param_name, param_value in pairs(opt_curr.default) do
file_opt[param_name] = param_value file_opt[param_name] = param_value
if file_opt_curr then if file_opt_curr then
param_value = file_opt_curr[param_name] local param_value_curr = file_opt_curr[param_name]
if param_value ~= nil then if param_value_curr ~= nil then
file_opt[param_name] = param_value file_opt[param_name] = param_value_curr
end end
end end
end end

View File

@ -296,31 +296,25 @@ function Param:trim()
self:slice(1, #self.text - #self.text:match('%s*$')) self:slice(1, #self.text - #self.text:match('%s*$'))
self:slice(1 + #self.text:match('^%s*'), #self.text) self:slice(1 + #self.text:match('^%s*'), #self.text)
if self.text:match('^' .. self.opt.line_prefix) then local text = ''
self:slice(1 + #self.opt.line_prefix, #self.text) local literals = {}
end local offset = self.offset
if self.opt.trim_inner_spaces then for i = 1, #self.text do
local text = '' local char = self.text:sub(i, i)
local literals = {} local literal = self.literals[i]
local offset = self.offset
for i = 1, #self.text do if literal or not char:match('%s') or not text:match('%s$') then
local char = self.text:sub(i, i) text = text .. char
local literal = self.literals[i] table.insert(literals, literal)
elseif offset and offset >= i then
if literal or not char:match('%s') or not text:match('%s$') then self.offset = math.max(1, self.offset - 1)
text = text .. char
table.insert(literals, literal)
elseif offset and offset >= i then
self.offset = math.max(1, self.offset - 1)
end
end end
self.text = text
self.literals = literals
end end
self.text = text
self.literals = literals
return #self.text > 0 return #self.text > 0
end end
@ -391,9 +385,9 @@ function ParamList:parse()
for col = start_col, stop_col do for col = start_col, stop_col do
self:update(line:sub(col, col), brace_stack, Cursor.new(row, col)) self:update(line:sub(col, col), brace_stack, Cursor.new(row, col))
end end
self:flush()
end end
self:flush()
end end
-- --
@ -535,7 +529,6 @@ function WrapContext:wrap()
local is_last_param = i == #self.params.parsed local is_last_param = i == #self.params.parsed
if self.opt.comma_prefix then if self.opt.comma_prefix then
builder:update(self.opt.line_prefix)
if not is_first_param then if not is_first_param then
builder:update(', ') builder:update(', ')
elseif self.opt.comma_prefix_indent and not is_last_param then elseif self.opt.comma_prefix_indent and not is_last_param then
@ -543,7 +536,6 @@ function WrapContext:wrap()
end end
cursor = self:update_builder_param(builder, param) or cursor cursor = self:update_builder_param(builder, param) or cursor
else else
builder:update(self.opt.line_prefix)
cursor = self:update_builder_param(builder, param) or cursor cursor = self:update_builder_param(builder, param) or cursor
if not is_last_param or self.opt.comma_last then if not is_last_param or self.opt.comma_last then
builder:update(',') builder:update(',')
@ -562,7 +554,6 @@ function WrapContext:wrap()
end end
if self.opt.brace_last_wrap then if self.opt.brace_last_wrap then
builder:update(self.opt.line_prefix)
builder:update(self.suffix) builder:update(self.suffix)
builder:flush() builder:flush()
end end