Last active
April 20, 2022 14:37
-
-
Save fcsest/010bf225e862813321e0f41d24d04723 to your computer and use it in GitHub Desktop.
My Rprofile for development in VSCode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setting options | |
options(width = 80) | |
# we set the cloud mirror, which is "network-close" to everybody, as default | |
local({ | |
r <- getOption("repos") | |
r["CRAN"] <- "https://cloud.r-project.org" | |
options(repos = r) | |
}) | |
# setup packages for development | |
if (interactive()) { | |
if (Sys.getenv("TERM_PROGRAM") == "vscode") { | |
# obtain list of packages in system library currently | |
lib_packages <- names(utils::installed.packages()[, 3]) | |
if (!"remotes" %in% lib_packages) { | |
message("installing remotes package") | |
utils::install.packages("remotes") | |
} | |
if (!"renv" %in% lib_packages) { | |
message("installing renv package") | |
remotes::install_github("rstudio/[email protected]") | |
} | |
if (!"jsonlite" %in% lib_packages) { | |
message("installing jsonlite package") | |
remotes::install_github("jeroen/[email protected]") | |
} | |
if (!"rlang" %in% lib_packages) { | |
message("installing rlang package") | |
remotes::install_github("r-lib/[email protected]") | |
} | |
if (!"rstudioapi" %in% lib_packages) { | |
message("installing rstudioapi package") | |
remotes::install_github("rstudio/[email protected]") | |
} | |
if (!"vscDebugger" %in% lib_packages) { | |
message("installing vscDebugger package") | |
remotes::install_github("ManuelHentschel/[email protected]") | |
} | |
if (!"prompt" %in% lib_packages) { | |
message("installing prompt package") | |
remotes::install_github("gaborcsardi/[email protected]") | |
} | |
if (!"usethis" %in% lib_packages) { | |
message("installing usethis package") | |
remotes::install_github("r-lib/[email protected]") | |
} | |
if (!"devtools" %in% lib_packages) { | |
message("installing devtools package") | |
remotes::install_github("r-lib/[email protected]") | |
} | |
if (!"languageserver" %in% lib_packages) { | |
message("installing languageserver package") | |
remotes::install_github("REditorSupport/[email protected]") | |
} | |
if (!"languageserver" %in% lib_packages) { | |
message("installing languageserver package") | |
remotes::install_github("REditorSupport/[email protected]") | |
} | |
if (!"httpgd" %in% lib_packages) { | |
message("installing httpgd package") | |
remotes::install_github("nx10/httpgd") | |
} | |
options(vsc.rstudioapi = TRUE) | |
} | |
# attach R terminal to VSCode | |
ifelse( | |
.Platform$OS.type == "windows", | |
"USERPROFILE", | |
"HOME" | |
) |> | |
Sys.getenv() |> | |
file.path( | |
".vscode-R", | |
"init.R" | |
) |> | |
source() | |
# Change console prompt line | |
prompt::set_prompt(prompt::prompt_fancy) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment