Consider sticky leading arguments
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 446
- Forks
- 32
- Avg merge
- 16h 48m
- Merged PRs (30d)
- 1
Description
For:
switch()- R6, S7, ggproto (e.g. https://github.com/tidyverse/ggplot2/blob/main/R/coord-map.R#L156)
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing how Air formats switch() and the leading arguments in R6, S7, or ggproto-style calls. Read the formatter and configuration handling for air.toml, then determine whether sticky arguments should be special-cased or configured by function name and count. Done means the chosen behavior is documented and the fully expanded style remains opt-in where specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100