Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support aligning leading commas with leading { and ( #77

Open
Tracked by #117
ddickstein opened this issue Dec 24, 2022 · 5 comments
Open
Tracked by #117

Support aligning leading commas with leading { and ( #77

ddickstein opened this issue Dec 24, 2022 · 5 comments

Comments

@ddickstein
Copy link

ddickstein commented Dec 24, 2022

Can an option to be added to support aligning commas with { and ( to enable this style:

local my_table =
  { foo
  , bar
  , baz
  }
@CppCXY
Copy link
Owner

CppCXY commented Dec 25, 2022

this is a very unusual style, is there any particular reason

@ddickstein
Copy link
Author

I grant that it's uncommon. I think it's a style that tends to be more favored in languages that do not allow trailing commas because it removes the friction of editing the end of the list of fields (at the cost of adding friction when editing the start of the list). I think the argument for supporting it in Lua is mostly for trying to keep similar styles across a multi-lingual codebase where the comma-leading style has been adopted in other places. For example, in a Neovim codebase you might have Vimscript and Lua mixed, and the reason you might adopt a leading comma style in Vimscript is that the \ for continuing on the next line is placed in the leading position, so it more naturally lends itself to something like:

let x =
  \{ 'key1': value1
  \, 'key2': value2
  \}

The other arguable benefit of a leading-comma style is that it keeps the logic on the left and the data on the right - similar to the reason you might want to break up a long if long_condition_1 and long_condition_2 then ... end as

if long_condition_1
and long_condition_2
then
  ...
end

@CppCXY
Copy link
Owner

CppCXY commented Dec 26, 2022

I accept this reason, but it will take time to study

@CppCXY CppCXY mentioned this issue Jan 4, 2023
16 tasks
@CppCXY
Copy link
Owner

CppCXY commented Jan 16, 2023

leading comma for '{' :

local t =
    { a = 123
    , kjfolw = 123
    , sjofjmwo = 123
    }

for '(':

callll
    ( aaa
    , bbb
    , ccc
    )

but what does '[' look like?

@ddickstein
Copy link
Author

Good point - it doesn't apply in lua. I'll remove it from the title and original post.

@ddickstein ddickstein changed the title Support aligning leading commas with leading {, [, and ( Support aligning leading commas with leading { and ( Jan 16, 2023
@CppCXY CppCXY mentioned this issue Feb 7, 2023
7 tasks
@CppCXY CppCXY mentioned this issue Mar 29, 2023
5 tasks
@CppCXY CppCXY mentioned this issue Jun 13, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants