REditorSupport / REditorSupport/vscode-R
Working directory inference from '.Rproj' files
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 139
- Avg merge
- 2h 46m
- Merged PRs (30d)
- 5
Description
I apologize in advance if this issue has been asked/closed/addressed! I couldn't find it in the issues tab or the wiki.
Is your feature request related to a problem? Please describe.
It's not a huge problem, but it would be nice to have an option making the generated R session (e.g. when a piece of R code is run through 'R: Run Comnand in Terminal') be created with the working directory set to the R project that the code was written in. This would match the paradigm of R projects and offer support similar to that of RStudio
For example, in a VSCode workspace resembling:
- top-level-folder
- my-r-project
- my-r-project.Rproj
- script-1.R
- a-different-folder
- script-2.R
- a-different-project.Rproj
If code from script-1.R was run, it would be nice for it to be run relative to my-r-project, rather than top-level-folder (as is the current behavior).
Describe the solution you'd like
An option called r.workingdirectory, with possible values being
workspace: uses the highest folder in the VSCode workspace that the code was run in, I believe this matches the default behaviorRproj: beginning from the directory of the file, looks for a .Rproj file; if it sees one, it uses that directory, if it doesn't, it looks one directory higher and repeats until either R_HOME or '/' is reachedfile: uses the directory that this file is contained in, without looking any higher
Describe alternatives you've considered
The alternative and current strategy is to simply run setwd() when the working directory does not match what is desired, which is still not that bad.
Edit: I've found another alternative is to edit '~/.vscode-R/init.R', which could serve as a per-user workaround. I think a dedicated option would still be best, but yep!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the R: Run Command in Terminal command and how it selects the working directory. Review the proposed r.workingdirectory values and the .Rproj search behavior in the issue. Done means each option uses the specified directory, including fallback behavior when no .Rproj file is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r, typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100