posit-dev / posit-dev/air

Consider sticky leading arguments

Open
#233 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
446
Forks
32
Avg merge
16h 48m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.