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 treating .Rproj as a "virtual" air.toml #153

Open
DavisVaughan opened this issue Jan 14, 2025 · 0 comments
Open

Consider treating .Rproj as a "virtual" air.toml #153

DavisVaughan opened this issue Jan 14, 2025 · 0 comments

Comments

@DavisVaughan
Copy link
Collaborator

DavisVaughan commented Jan 14, 2025

With @lionel-:

During TOML discovery, we could also consider looking for .Rproj files "for historical reasons".

We'd treat .Rproj as nearly at the same level as air.toml in terms of importance, like:

air.toml > .Rproj > editor settings > air defaults

If we don't detect an air.toml, but do detect an .Rproj, then we would not consider any other settings, even if we were in VS Code / Positron. It would be like having an air.toml which overrides everything else to help enforce project level settings that everyone is forced to use.

An .Rproj looks like this, with UseSpacesForTab and NumSpacesForTab being the most important that we'd be looking for. We'd translate those into an in memory virtual air.toml and use that virtual toml file.

Version: 1.0
ProjectId: ad2d6033-a5dd-4de0-8c51-ed8a768f5b37

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

This would be nice for people that only work in RStudio because the workflow would be like:

  • Update RStudio UI, which changes the on disk .Rproj
  • Just rerun air format at the CLI over all files in the directory or save a file where Format on Save is active

Since air is treated as a CLI tool in RStudio, there is no syncing that needs to occur, it would just rediscover that updated .Rproj before the next format request.


The upside is that it means the settings RStudio uses for automatic indentation are in sync with what air tries to format your code to without extra effort.

The downside is that it would be one more level of potential confusion. And if you transition to Positron from RStudio you might be confused about why (kind of hidden) RStudio settings are being preferred over your editor settings.

An alternative is to have an easy way to create an air.toml from an .Rproj, but this won't have the nice property of staying in sync with the RStudio UI.

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