From 68a581f12b606f94bc815c7233dacfc8495f04ec Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 31 Dec 2024 10:20:43 -0800 Subject: [PATCH] Support more options, better wrapping --- lua/argonaut/options.lua | 1 - lua/argonaut/param.lua | 3 +-- lua/argonaut/range.lua | 21 +++++++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lua/argonaut/options.lua b/lua/argonaut/options.lua index 0059e0f..e7a9d0e 100644 --- a/lua/argonaut/options.lua +++ b/lua/argonaut/options.lua @@ -6,7 +6,6 @@ local options_current = { comma_last = false, comma_prefix = false, comma_prefix_indent = false, - line_max = 32, }, go = { comma_last = true, diff --git a/lua/argonaut/param.lua b/lua/argonaut/param.lua index 9a792d2..8aea334 100644 --- a/lua/argonaut/param.lua +++ b/lua/argonaut/param.lua @@ -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 diff --git a/lua/argonaut/range.lua b/lua/argonaut/range.lua index 7fc5d4a..f5302ab 100644 --- a/lua/argonaut/range.lua +++ b/lua/argonaut/range.lua @@ -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