Skip to content

Commit

Permalink
feat: first version (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanouil authored Oct 15, 2023
1 parent 0b0f6af commit ad2b9e8
Show file tree
Hide file tree
Showing 62 changed files with 5,908 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
if (nzchar(system.file(package = "cli"))) {
cli::cli_alert_info(R.version.string)
cli::cli_alert_warning(paste0("Config '", cli::col_green("~/.Rprofile"), "' was loaded!"))
} else {
message(R.version.string)
message("Config '~/.Rprofile' was loaded!")
}

source("renv/activate.R")

options(
languageserver.formatting_style = function(options, ...) {
transformers <- styler::tidyverse_style(indent_by = options$tabSize, ...)
transformers$indention$update_indention_ref_fun_dec <- NULL
transformers$indention$unindent_fun_dec <- NULL
transformers$line_break$remove_line_breaks_in_fun_dec <- NULL
transformers
},
knitr.progress.fun = function(total, labels) {
id = cli::cli_progress_bar(
total = total, .auto_close = FALSE
)
list(
update = function(i) {
cli::cli_progress_update(id = id)
},
done = function() {
cli::cli_process_done(id)
}
)
}
)

Sys.setenv(CHROMOTE_CHROME = "/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser")

if (interactive()) {
options(
repos = c(
"CRAN" = if (is.null(getOption("repos")[["CRAN"]]) || getOption("repos")[["CRAN"]] %in% "@CRAN@") {
"https://cran.r-project.org/"
} else {
getOption("repos")[["CRAN"]]
}
),
width = 150,
menu.graphics = FALSE
)

if (nzchar(system.file(package = "prompt"))) prompt::set_prompt(prompt::prompt_git)
}

# webshot2::webshot(
# url = "gentle-intro-to-quarto.html",
# file = "gentle-intro-to-quarto.png",
# vwidth = 1920,
# vheight = 1080
# )
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# From https://github.com/devcontainers/images/tree/main/src/base-ubuntu
# [Choice] Ubuntu version (use jammy on local arm64/Apple Silicon): jammy, focal
ARG VARIANT="jammy"
FROM buildpack-deps:${VARIANT}-curl

LABEL dev.containers.features="common"
69 changes: 69 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// For format details, see https://aka.ms/devcontainer.json.
// Base image from https://github.com/devcontainers/images/tree/main/src/base-ubuntu.
{
"name": "Quarto",
// "image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
"build": {
"dockerfile": "./Dockerfile",
"context": ".",
"args": {
"VARIANT": "jammy"
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "vscode",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
// Setup a non-root user. Note that UID and GID will be updated with local user values.
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
// To latest the latest build of Git.
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
"ppa": "false"
},
// To install the latest RIG v1.*.
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": {
"version": "release", // To install the latest R version (default) and other.
"vscodeRSupport": "full",
"installDevTools": "false",
"installREnv": "false",
"installRMarkdown": "false"
},
// To install the latest Python
// "ghcr.io/devcontainers/features/python:1": {
// "version": "latest"
// },
// To install the latest Quarto v1.*.
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
"version": "prerelease",
"installTinyTex": "false",
"installChromium": "true"
}
},

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"quarto.quarto",
"REditorSupport.r",
"usernamehw.errorlens"
],
"settings": {
"r.rterm.option": [
"--no-save",
"--no-restore-data",
"--quiet"
]
}
}
},
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_freeze
.quarto
.luarc.json
*_cache
*_files
**.html
/.quarto/
/.luarc.json
webr-*.js
8 changes: 8 additions & 0 deletions _dependencies.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
library(cli)
library(httpgd)
library(languageserver)
library(knitr)
library(reticulate)
library(prompt)
library(webshot2)
library(rmarkdown)
8 changes: 8 additions & 0 deletions _extensions/coatless/webr/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: webr
title: Embedded webr code cells
author: James Joseph Balamuta
version: 0.3.6
quarto-required: ">=1.2.198"
contributes:
filters:
- webr.lua
31 changes: 31 additions & 0 deletions _extensions/coatless/webr/template.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: "WebR-enabled code cell"
format: html
engine: knitr
#webr:
# show-startup-message: false # Display status of webR initialization
# show-header-message: false # Check to see if COOP&COEP headers are set for speed.
# packages: ['ggplot2', 'dplyr'] # Pre-install dependencies
# home-dir: "/home/rstudio" # Customize where the working directory is
# base-url: '' # Base URL used for downloading R WebAssembly binaries
# service-worker-url: '' # URL from where to load JavaScript worker scripts when loading webR with the ServiceWorker communication channel.
filters:
- webr
---

## Demo

This is a webr-enabled code cell in a Quarto HTML document.

```{webr-r}
1 + 1
```

```{webr-r}
fit = lm(mpg ~ am, data = mtcars)
summary(fit)
```

```{webr-r}
plot(pressure)
```
Loading

0 comments on commit ad2b9e8

Please sign in to comment.