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

Fix r profile #399

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions R/rix_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ is_rstudio_session <- function(message_type = c("simple", "quiet", "verbose")) {
return(is_rstudio)
}


#' If not yet present, add the Nix default path of the system-wide profile to
#' `PATH` environment variable inside R session.
#'
Expand Down Expand Up @@ -421,6 +420,8 @@ nix_rprofile <- function() {
quote({
is_rstudio <- Sys.getenv("RSTUDIO") == "1"
is_nix_r <- nzchar(Sys.getenv("NIX_STORE"))
is_code <- Sys.getenv("TERM_PROGRAM") == "vscode"
is_positron <- Sys.getenv("POSITRON") == "1"
if (isFALSE(is_nix_r) && isTRUE(is_rstudio)) {
# Currently, RStudio does not propagate environmental variables defined in
# `$HOME/.zshrc`, `$HOME/.bashrc` and alike. This is workaround to
Expand Down Expand Up @@ -481,8 +482,16 @@ nix_rprofile <- function() {
.libPaths(new_paths)
rm(current_paths, userlib_paths, user_dir, new_paths)
}

rm(is_rstudio, is_nix_r)
# source vscode-R init.R file for vscode-R
if (isTRUE(is_code) && interactive() && isFALSE(is_rstudio) && isFALSE(is_positron)) {
vscode_r_init <- file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R")
if (file.exists(vscode_r_init)) {
source(vscode_r_init)
} else {
message("No .vscode-R/init.R file found. If you want to use VSCode-R, you need to source it in your .Rprofile or start vscode from within nix-shell")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the extension called VSCode-R? Is it this one? https://open-vsx.org/extension/REditorSupport/r

Shouldn't it be REditorSupport?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well it's often called vscode-R and it's stored in the location .vscode-R.
Here the github repo also says vscode-R https://github.com/REditorSupport/vscode-R.
As far as I know it's the only (or at least only official) R extension in vscode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

}
}
rm(is_rstudio, is_nix_r, is_code, is_positron)
# nolint end: object_name
})
# nolint end: object_name
}
Loading