-
Notifications
You must be signed in to change notification settings - Fork 129
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
Accessing VS Code settings in R #743
Accessing VS Code settings in R #743
Conversation
** proof of concept ** Load R-related vsc settings and set as R option
Is this meant to completely replace/overwrite the options set in .Rprofile? |
I think ideally this would just be a more user-friendly way of setting options, and would be overwritten by the user's .Rprofile options |
R/init.R
Outdated
# Attach to vscode | ||
exports$.vsc.attach() | ||
|
||
# Import VSC-R settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some settings (e.g. vsc.plot
, vsv.use_httpgd
, vsc.rstudioapi
) must be set before the init.R
is sourced.
I move loading settings from Also, each time |
R/vsc.R
Outdated
# settings.json can result in errors if read via fromJSON | ||
vsc_settings <- suppressWarnings( | ||
unlist( | ||
jsonlite::fromJSON(paste(readLines(settings_file), collapse = "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use jsonlite::read_json()
? Could you provide a case where "settings.json can result in errors if read via fromJSON"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think this was fixed since relying on the ~/.vscode-r settings.json. Can no longer replicate issues with readJSON
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Let me refine the code a bit so that naming conventions are more consistent.
Update the viewColumn item's description
Thank you for updating the code @renkun-ken, it's working quite nicely now! |
Works nicely, thanks! |
* PoF accessing VSC settings ** proof of concept ** Load R-related vsc settings and set as R option * Update getSettings.R * Fiddle with configurations * Setup example usage * Write settings.json to .vscode-R folder * Source vscode settings first * Move import back to init, only replace ops if null * Update package.json * Descriptive names, move settings under categories * Change setting names * Load settings before attach * Refine load_settings * Fix * Update viewColumn setting Update the viewColumn item's description * Minor typos * Use expression mapping * Use quote list Co-authored-by: Kun Ren <[email protected]> Co-authored-by: Manuel Hentschel <[email protected]>
proof of concept
This PR allows loading R-related vsc settings in R. This reduces the reliance on
setting options in the .Rprofile, and means that you don't need to have settings that have no effect outside of VSC-R. This also allows maintainers to restrict invalid inputs.
This could also be used for increased customisation E.g., as outlined by @renkun-ken, this could be extended to modify .Rprofile execution order
Note: .Rprofile settings (intentionally) have higher priority over VSCode settings, and will overwrite when necessary
Caveats:
The default value of a setting must be identical to the R option default, as VSCode settings are not written to the settings.kson unless the default value is changed.May require an environment term to locate the settings.json in some casesScreenshot
Note: this PR is a proof-of-concept, and is a little rough around the edges. I'd love to hear whether this is something that is useful, and any ideas/issues with the implementation