posit-dev / posit-dev/air

Parenthesised [] pipelines

Open
#474 2 comments 1 reaction 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

Sorry if not relevant, I was not capable of finding my answer in the docs and there's no discussion Q&A section in this repo, so I ask my question here.

I want to have my project to format the code in this way:

library(data.table)
cw <- data.table(ChickWeight)

# fmt: skip
cw21 <- (
  cw[Time %in% c(0, 21)]
  [, Weight := weight] 
  [, Group := factor(paste0("Diet_", Diet))]
  [, .(Chick, Group, Time, Weight)]
  [order(Chick, Time)]
  [1:5]
)

By default, is formatted this way:

# Air formatter by default
cw21 <- (cw[Time %in% c(0, 21)][, Weight := weight][,
  Group := factor(paste0("Diet_", Diet))
][, .(Chick, Group, Time, Weight)][order(Chick, Time)][1:5])

I tried different options in air.toml file skip formatting options, but I'm lost.

# Air formatter with air.toml with [format] skip = ["[", "]", "`[`", "`]`"]
cw21 <- (cw[Time %in% c(0, 21)][, Weight := weight][,
  Group := factor(paste0("Diet_", Diet))
][, .(Chick, Group, Time, Weight)][order(Chick, Time)][1:5])

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

No files, tests, or entry points are named. Start by locating the formatter logic for parenthesised R expressions and chained [] calls, then compare it with the requested multiline output; done means the example formats as shown without relying on skip settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.