Skip to content
jbearakPublic

Repository files navigation

Raven

Raven finds undefined variables and broken source() chains in R code, across files and as you type, without running your code. It is a language server for R, so the same analysis drives completion, go to definition, find references, and hover in VS Code, Neovim, Zed, or any editor that speaks the Language Server Protocol. A command-line raven check runs it in CI.

Here, analysis.R sources helpers.R, which defines clean_names():

source("helpers.R")

survey <- clean_names(read.csv("survey.csv"))
summary(servey$age)

plot(fit)
fit <- lm(age ~ income, data = survey)
$ raven check .
analysis.R:4:9 warning: servey is not defined [undefined-variable]
analysis.R:6:6 warning: fit is used before it is defined (defined on line 7) [undefined-variable]
2 issues (0 errors, 2 warnings, 0 infos, 0 hints, 0 notes)

VS Code showing a yellow squiggle under summarize_score and the hover message "summarize_score is not defined (undefined-variable)"

The same check in VS Code, from the Getting started tutorial (Raven 0.21.1).

Raven knows clean_names came from helpers.R, so it doesn't flag it. It flags the typo and the plot that runs before the model exists. Style linters such as lintr and Jarl check how each line is written; Raven checks whether every name your code uses exists at that point, following source() across files, and it runs alongside them. In your editor, the same warnings appear as you type. No R session is involved, and the output above was produced with R turned off.

Installation

  • VS Code: install Raven from the Marketplace. The extension includes the language server.
  • Cursor, Positron, VSCodium: install from Open VSX.
  • Other editors: install the raven binary (below), then follow Editor setup for Neovim, Zed, Helix, Emacs, and others.

Open a folder of R files and Raven starts on its own: problems show up as squiggles and in the Problems panel, with nothing else to install and no R needed. Getting started walks through a first example in two minutes.

Command line

The raven binary is the language server and the CLI.

  • macOS (Apple Silicon): brew install jbearak/raven/raven. Use the full name, since Homebrew core has an unrelated raven.
  • Ubuntu: use the signed apt repository. See Ubuntu installation.
  • Arch Linux: the community AUR packages raven and raven-bin, maintained by Novica.
  • Anything else: download a binary from the releases page, or build from source with cargo install --git https://github.com/jbearak/raven raven.

To run Raven on every pull request, see Raven in CI. GitHub Actions users can install it with jbearak/setup-raven@v1.

What you get

Analysis

Navigation and editing

R session (VS Code)

  • An R console that runs your installed R, with code sent straight from the editor.
  • A debugger with breakpoints, stepping, variables, and the Debug Console.
  • Plot, data, and help viewers. The data viewer stays fast on millions of rows.

R Markdown, Quarto, and CI

Why static analysis

Raven reads your files instead of asking a running R session what exists. That has four consequences:

  • It answers the moment you open a file, even code that errors halfway or that you're only reading.
  • It reflects what the file says, not what your session remembers from an hour ago.
  • It never runs your code, so it is safe on any project and behind an AI agent.
  • It runs anywhere, including CI, with no R installed.

How Raven compares covers RStudio, Positron, vscode-R, lintr, Jarl, and Air.

Works with your setup

Raven adds to the R tools you already use. Its language server and R console run alongside vscode-R's, and Raven asks which console to send code to. In Positron, Raven's console and viewers step aside. Using Raven with other R tools explains each combination.

Documentation

Project settings go in a raven.toml at the project root, which Raven finds by searching upward from the folder you open; VS Code settings and a .lintr work too. See Configuration.

All pages are listed in the documentation hub, and the documentation site has the same pages with search. Start with Getting started, and see Troubleshooting or the FAQ when something is unclear. Raven is under active development; bug reports and feedback are welcome in issues.

Raven's sibling project Sight is a language server for Stata with the same cross-file model.

Contributors: development notes cover building, testing, and internals.

Acknowledgements

Raven builds on, learns from, and tests against these open-source projects. NOTICE has the license texts for the code Raven copies or vendors.

  • Where Raven started. Raven began as the language server extracted from Ark (Posit Software, PBC, MIT), which supplied its first LSP wiring and tree-sitter setup. Its cross-file model, the directives and the position-aware scope, comes from Raven's sister project Sight (GPL-3.0).
  • Parsing. tree-sitter-r (Kevin Ushey, Jim Hester, Davis Vaughan, MIT) parses every R file Raven reads, on top of Tree-sitter (Max Brunsfeld and contributors, MIT). tree-sitter-stan (Brian Ward, MIT), pinned to an audited revision, parses Stan for syntax diagnostics. Raven wrote its own JAGS grammar and used both as structural references. The language server speaks LSP through tower-lsp (Eyal Kalderon, MIT or Apache-2.0).
  • Linting. Raven's rules, its reading of .lintr, and its # nolint comments follow lintr (Jim Hester, Michael Chirico and the lintr authors, MIT). Raven's compatibility tests adapt behavioral cases from lintr's test suite, and its list of base S3 generics is ported from lintr.
  • Stan and JAGS. Raven generates its Stan function and distribution metadata with the stanc3 npm package 2.39.1 (Brian Ward), which bundles the Stan compiler 2.39.0 (Stan Development Team, BSD-3-Clause). Raven's JAGS parser and JAGS 4.3.2 catalog are clean-room interoperability artifacts built from independently authored syntax rules and factual metadata, checked against the official JAGS command line. The source URL and SHA-256 are kept for reproducibility. Raven does not copy or bundle JAGS code or documentation. Models published by the Stan and JAGS projects serve as a held-out test set and don't ship with Raven.
  • Package data. Raven's downloadable package-symbol database is built from CRAN and Bioconductor metadata published by r-universe, maintained by rOpenSci. See Package database. The base-package data built into the binary is captured from R itself (R Core Team, GPL-2 or GPL-3). A regression suite runs raven check over the sources of published R packages, with thanks to their authors.
  • Syntax highlighting. The bundled R and R Markdown TextMate grammars come from vscode-R-syntax (REditorSupport, MIT). Knit Preview tokenizes code with vscode-textmate and vscode-oniguruma (Microsoft, MIT).
  • R session. The console's line editor is reedline (the Nushell Project, MIT). The plot viewer shows plots from httpgd (Florian Rupprecht, GPL-2.0 or later). The data viewer reads Apache Arrow files that the R arrow package writes (Apache Software Foundation, Apache-2.0) and draws them with Glide Data Grid (Glide, MIT). Its grid theme is ported from Raven's sibling project table-viewer (GPL-3.0), whose column sizing and bounded row cache it also follows. Its design borrows details from vscode-R, pillar, VisiData and julia-vscode, and studied RStudio's View() and Positron's Data Explorer. Knit Preview runs knitr (Yihui Xie, GPL) and exports with Pandoc (John MacFarlane, GPL-2.0 or later), and Quarto Preview runs Quarto (Posit Software, PBC, MIT).
  • Debugger. Raven defines Ark's .ark_annotate_source hook, which pkgload and shiny (Posit Software, PBC, MIT) call, so breakpoints work in load_all() code and Shiny apps as they do in Positron. Several of the debugger's defaults and techniques come from Ark, RStudio, debugpy (Microsoft, MIT), and vscDebugger (Manuel Hentschel, MIT), the R side of the R Debugger extension.
  • Comparisons. How Raven compares sets Raven beside RStudio, Positron, vscode-R and its languageserver, lintr, Jarl, and Air. The documentation's layout follows conventions from the docs of Ruff, uv, and similar tools.

License

GPL-3.0. See NOTICE for third-party attributions.

Releases

Packages

Used by

Contributors

Languages