Support more options, better wrapping
This commit is contained in:
parent
a64cac9be8
commit
68a581f12b
@ -6,7 +6,6 @@ local options_current = {
|
||||
comma_last = false,
|
||||
comma_prefix = false,
|
||||
comma_prefix_indent = false,
|
||||
line_max = 32,
|
||||
},
|
||||
go = {
|
||||
comma_last = true,
|
||||
|
@ -93,10 +93,9 @@ end
|
||||
function Param:is_wrapped()
|
||||
local previous_param = self:get_previous()
|
||||
if previous_param then
|
||||
-- print(get_param_stop_row(previous_param), get_param_start_row(self))
|
||||
return get_param_stop_row(previous_param) ~= get_param_start_row(self)
|
||||
else
|
||||
return false
|
||||
return self.range.start_cursor.row ~= get_param_start_row(self)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -147,12 +147,25 @@ function Range:write(builder, wrapped)
|
||||
builder:push_indent()
|
||||
|
||||
for i, param in ipairs(self.params) do
|
||||
param:write(builder)
|
||||
|
||||
local is_first_param = i == 1
|
||||
local is_last_param = i == #self.params
|
||||
if not is_last_param or self:query_option('comma_last') then
|
||||
builder:write(',')
|
||||
|
||||
if self:query_option('comma_prefix') then
|
||||
if is_first_param then
|
||||
if self:query_option('comma_prefix_indent') then
|
||||
builder:write(' ')
|
||||
end
|
||||
else
|
||||
builder:write(', ')
|
||||
end
|
||||
param:write(builder)
|
||||
else
|
||||
param:write(builder)
|
||||
if not is_last_param or self:query_option('comma_last') then
|
||||
builder:write(',')
|
||||
end
|
||||
end
|
||||
|
||||
if not is_last_param then
|
||||
builder:endline()
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user