Skip to content

Fred-Wu/vscode-R-console

Repository files navigation

R Console

R Console is a lightweight R console for VS Code that runs R inside a custom pseudoterminal. It combines a console frontend, a bundled R backend, and a console-scoped language server client. It is designed to work with VS Code, the vscode-R extension, and R's languageserver package.

Features

  • Custom R console hosted in the VS Code terminal area.
  • Persistent R console sessions that can be attached, detached, or closed from VS Code.
  • Tab-triggered completion and signature help, including objects from the active R session and runtime $ / @ member completion.
  • Syntax highlighting with semantic-token styling when languageserver is available.
  • Multiline editing with local history navigation, reverse search, and long-input rendering.
  • Auto-matching brackets and quotes.
  • Bracketed paste handling.
demo.mp4
Screen.Recording.2026-05-02.at.4.13.33.pm.mov

Using R Console

Setup

  1. Install vscode-R.

  2. Configure the platform-specific vscode-R R path setting, or make sure R is available from R_HOME or PATH:

    • Windows: r.rpath.windows
    • macOS: r.rpath.mac
    • Linux: r.rpath.linux
  3. Enable bracketed paste mode:

    "r.bracketedPaste": true
  4. To make vscode-R commands target R Console, enable:

    "r.alwaysUseActiveTerminal": true
  5. Optional: keep the vscode-R session watcher enabled for active-session object completion and runtime $ / @ member completion:

    "r.sessionWatcher": true

    This setting is enabled by default unless explicitly set to false.

  6. Optional: install the R package languageserver for completion, signature help, and semantic highlighting.

R Console launches from r.rpath.*, R_HOME, or PATH. It does not launch from r.rterm.windows, r.rterm.mac, or r.rterm.linux.

Important

Only official vscode-R 2.8.x releases are currently supported. Newer vscode-R builds are moving to a WebSocket and JSON-RPC 2.0 based architecture. A future R Console update will support both vscode-R architectures once the new architecture is officially released.

Launch R Console

Launch R Console from the Command Palette:

  • R Console: Create R Console
  • R Console: Create R Console in Side Editor

Persistent Session Management

Use R Console: Manage Persistent Sessions... to manage running R Console sessions.

  • Attach to a detached R Console session.
  • Detach a console UI or close VS Code while leaving the R process running.
  • Close a session and stop its R process.
  • Restore a dropped console UI after workspace folder changes or an extension host reload.

Configuration

R Console reads several settings from vscode-R:

Setting Purpose
r.rpath.windows R executable path on Windows for R Console startup
r.rpath.mac R executable path on macOS for R Console startup
r.rpath.linux R executable path on Linux for R Console startup
r.rterm.option Extra arguments passed to R
r.sessionWatcher Enables the vscode-R session watcher bridge
r.bracketedPaste Enables bracketed paste mode
r.lsp.args Extra arguments passed when starting languageserver
r.lsp.use_stdio Uses stdio instead of a loopback socket for the console LSP client when supported
r.alwaysUseActiveTerminal Controls whether the new console is immediately focused

If r.rpath.* is set, an ambient R_HOME does not override it. If r.rpath.* is unset, ambient R_HOME is used before PATH.

R Console also contributes its own settings:

Setting Default Purpose
r.console.autoMatch true Auto-insert matching brackets and quotes
r.console.tabSize 2 Indentation width
r.console.pipeOperator |> Pipe operator inserted by R Console: Insert Pipe Operator / Ctrl+Alt+M; supported values are |> and %>%

Dependency Model

  • vscode-R is a hard dependency. R Console uses the same configured R binary.
  • R's languageserver package is optional at runtime but required for console semantic tokens, completion, and signature help.
  • The bundled R backend is required at runtime. If the bundled backend for the current target is missing, the console does not fall back to a separate backend.

Acknowledgements

R Console is built on the broader VS Code, Rust, and R ecosystems, and on the work of open-source projects that informed the extension. In particular:

  • vscode-R - R Console depends on vscode-R for configuration, session bootstrap, session watching, and the surrounding VS Code R workflow.
  • arf - The embedded-R host design was heavily informed by arf's Rust-based approach to loading and embedding R, platform-specific console initialization, callback wiring, event/input-handler pumping, and backend architecture.
  • Ark - The native R frontend model, nested-input handling, ReadConsole recovery concepts, and generic R event-loop integration were important references for the backend design.
  • rchitect - Rchitect was a reference for embedding R from a non-R host process, including R home/shared-library discovery and callback/FFI boundary concepts.
  • radian - The terminal-first interaction model and several console UX ideas, including multiline editing, history search/navigation, bracketed paste, and prompt-centric workflows, were inspired by radian.
  • languageserver - Console completion, signature help, and semantic-token support are built around R's language server.

Development Note

This extension's source code was written with assistance from GPT models using OpenAI's Codex. The overall feature design and logic decisions are mine; GPT models were used to generate and iterate on the implementation.

Contributing

See CONTRIBUTING.md for local setup, build, packaging, and manual testing links.

License

MIT

About

A lightweight R console for VS Code

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors