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

Consider sticky leading arguments #233

Open
lionel- opened this issue Feb 19, 2025 · 1 comment
Open

Consider sticky leading arguments #233

lionel- opened this issue Feb 19, 2025 · 1 comment

Comments

@lionel-
Copy link
Collaborator

lionel- commented Feb 19, 2025

For:

I.e. functions that have one or more leading setup arguments followed by a list of key-values. A common style for these is to write the leading arguments on the same line and only expand the list of key-values.

switch(foo,
  a = 1,
  b = 2
)

Air currently fully expands:

switch(
  foo,
  a = 1,
  b = 2
)

We could:

  • Special-case switch()
  • Add an air.toml section with a list of functions and the number of sticky argument

Using the array-of-objects syntax for toml:

[format]

[[format.sticky]]
name = "ggproto"
n = 2

# Undo the default special-case for `switch()`
[[format.sticky]]
name = "switch"
number = 0

The fully expanded style could still be opted-into via a persistent line.

@lionel-
Copy link
Collaborator Author

lionel- commented Feb 19, 2025

From @hadley:

IMO you only ever need one sticky arg
today I’d explicitly name the parent arg to ggproto()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant