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

Provide advice for tibble::tribble() calls #102

Closed
etiennebacher opened this issue Dec 13, 2024 · 2 comments
Closed

Provide advice for tibble::tribble() calls #102

etiennebacher opened this issue Dec 13, 2024 · 2 comments

Comments

@etiennebacher
Copy link

Hello, thank you for this tool! After using Ruff and rustfmt, I'm very happy to see fast formatting coming to R.

I was testing air on some packages and noticed that tibble::tribble() are reformatted with one element per line, which makes it harder to read:

Before:

tribble(
  ~colA, ~colB,
  "a",   1,
  "b",   2,
  "c",   3
)

After:

tribble(
  ~colA,
  ~colB,
  "a",
  1,
  "b",
  2,
  "c",
  3
)

I saw this was mentioned in #26 but the issue is now closed and I didn't find any mention of this in docs/formatter.md, so I'm just opening this so that it is tracked somewhere. I hope it's not a duplicate.

Thanks again


Tested on main with 093bb96

@DavisVaughan DavisVaughan changed the title tibble::tribble() wrongly formatted? Provide advice for tibble::tribble() calls Dec 16, 2024
@DavisVaughan
Copy link
Collaborator

Yes, right now there is no way to avoid the mess that you see here with tribble() calls.

We really want to avoid hardcoding any specific function names into the formatter. One idea is to turn off formatting altogether. You can't do this yet but it would look something like

# air format: ignore
tribble(
  ~x,   ~y
  1,    2
)

We are also considering more powerful comments that would actually help you enforce a particular format, like

# air format: layout-tabular
tribble(
  ~x,   ~y
  1,    2
)

This would snap you into a rectangular layout as you type to help you out (probably falling back to a "verbatim" what-you-see-is-what-you-get layout if the number of arguments doesn't divide evenly into a rectangle)

@lionel-
Copy link
Collaborator

lionel- commented Dec 17, 2024

Closing in favour of: #113

@lionel- lionel- closed this as completed Dec 17, 2024
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

3 participants