vscode-R
vscode-R copied to clipboard
`languageserver.formatting_style` in VSCode settings (not only options in `.Rprofile`)
Is your feature request related to a problem? Please describe.
I encountered the same issue on Windows as described in REditorSupport/languageserver#503.
It is not that trivial to figure out in what directory the "languageserver" was started and put the formatter/.Rprofile
in the proper location.
Describe the solution you'd like
Is there a way to set this in vscode-r settings (i.e., "r.lsp.formatting_style")? Maybe like for the knitr
command.
Are you sure you are linking to the right issue?
My bad, the issue is from the languageserver
repository REditorSupport/languageserver#503
It is not that trivial to figure out in what directory the "languageserver" was started and put the formatter/
.Rprofile
in the proper location.
I dont know why this is so hard for you.
Also, you should be able to put the .Rprofile
in your home directory, doesn't that solve the problem?
https://support.rstudio.com/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf
"hard" no.
The .Rprofile
does not live exactly in the same place on UNIX and Windows system.
For instance, on Windows, config files (ssh, gpg, git, etc.) can live in C:\Users\mcanouil
which would be the equivalent of /home/mcanouil
on UNIX.
Unfortunately, the home directory on Windows is not the root directory of the user, i.e., C:\Users\mcanouil\Documents
for R.
While every other options can be set either from options()
in an .Rprofile
or in VSCode settings, the formatter_style option cannot.
It would be way easier to have it in VSCode settings especially for cross platform access (e.g., settings sync) instead of having to create .Rprofile
on every local/remote containers/servers/computers.
Unfortunately, the home directory on Windows is not the root directory of the user, i.e.,
C:\Users\mcanouil\Documents
for R.
This is really hard to find but I believe it will be changed in R 4.2.0 to be released this month.
It would be way easier to have it in VSCode settings especially for cross platform access (e.g., settings sync) instead of having to create
.Rprofile
on every local/remote containers/servers/computers.
Wouldn't languageserver.formatting_style
be difficult to represent this in json (VSCode's configuration file is json, just in case) since this is essentially R code?
Instead, it seems to me that it would be better to change the styler
's settings so that they can be defined from the configuration file (r-lib/styler#319) and use those settings.
In fact, linting by languageserver
uses the lintr
's configuration file (.lintr
).
Wouldn't languageserver.formatting_style be difficult to represent this in json (VSCode's configuration file is json, just in case) since this is essentially R code?
I did not look at the vscode-r code, but such approach is already used for knitr/rmarkdown rendering, where, we can type an R function via the settings interface or directly in the json file (better to not have a function too big though).
Instead, it seems to me that it would be better to change the styler's settings so that they can be defined from the configuration file (https://github.com/r-lib/styler/issues/319) and use those settings. In fact, linting by languageserver uses the lintr's configuration file (.lintr).
I did not know that, since .lintr
is stored and read properly from C:\Users\mcanouil\Documents
or C:\Users\mcanouil
, it seems to be a good place to store styler/lintr rules.
This issue is stale because it has been open for 365 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
It really should be nice to have a feature like this because different projects can use different style guides (don't want to set this globally in .Rprofile) and making an .Rprofile local to my project then cases the global .Rprofile to not be run.