Skip to content

felix-andreas/roughly

Repository files navigation

Logo
Roughly

An extremely fast R language server and code formatter, written in Rust.
Docs · Releases · VS Code Extension

Note

Roughly can be used either as a standalone command-line tool or as an extension in supported editors like VS Code.

Why Roughly?

This project was created to address the slow performance of the existing R language server on large codebases. Originally called "The R(oughly good enough) language server", it began as a minimal but fast language server that supported only go-to-definition using regex-based indexing. Since then, the project has evolved into a full-featured language server with proper parsing, formatting, and linting, and the "good enough" part was eventually dropped from the name.

Features

Roughly aims to support the following language server features (some are experimental or in progress):

  • Formatting

    • Format entire document
    • Format selected code range (🧪 experimental)
  • Navigation

    • Index global variables, S4 and R6 classes/methods
    • Search current document - Ctrl + Shift + O in VS Code
    • Search global workspace - Ctrl + T in VS Code
    • Go to definition (🧪 experimental)
    • Find all references (🧪 experimental)
  • Diagnostics

    • Syntax errors - including missing or trailing commas
    • Basic linting rules - full list here
    • Warning for unused variables (🧪 experimental)
    • Error for undefined variable (⚠️ missing)
    • Argument validation for function calls (⚠️ missing)
    • Type checking (💡 early design phase)
  • Editing

    • Autocomplete local and global variables
    • Autocomplete variables from other packages (⚠️ missing)
    • Rename local variables (🧪 experimental)
    • Rename global variables (⚠️ missing)
    • Signature help (🔨 work in progress)

Roughly CLI

Usage

Run Roughly as a formatter:

roughly fmt           # Format all files in the current directory
roughly fmt <path>    # Format all files in `<path>`
roughly fmt --check   # Only check if files would be formatted
roughly fmt --diff    # Only show the diff if files would be formatted

To run Roughly as a linter:

roughly check         # Check all files in the current directory
roughly check <path>  # Check all files in `<path>`

Or, to run Roughly as a language server:

roughly server        # Usually started automatically by your editor

Installation

Download Binary (Recommended)

Download the pre-built binary for your platform from the releases page.

Install with Cargo

If you have Cargo installed, install Roughly with:

cargo install --git https://github.com/felix-andreas/roughly roughly

Build from Source

Alternatively, build from source:

cargo build --release

VS Code extension

Download from Marketplace (Recommended)

Install the extension from the VS Code Marketplace.

Note

The VS Code extension from the marketplace includes a bundled version of the Roughly CLI only for Windows and Linux x64. If you are using macOS or a different architecture, you will need to install the Roughly CLI manually.

Manual Installation

Alternatively, build the extension from source (or download from releases):

bun run package

Install the generated VSIX file:

code --install-extension roughly.vsix

Extension Settings

You can customize the Roughly extension in VS Code through the following settings:

{
  // Use a custom binary instead of the bundled one
  "roughly.path": "/path/to/roughly",
  // Pass custom arguments; defaults to ["server"]
  "roughly.args": ["server", "--verbose"],
  // Enable experimental features
  "roughly.experimentalFeatures": ["goto_definition", "range_formatting"],
}

Note

For a complete list of experimental features and their descriptions, see below.

Commands

You can access Roughly-specific commands in VS Code via the Command Palette (Ctrl+Shift+P):

  • Roughly: Open logs
  • Roughly: Start/Stop/Restart Server
  • Roughly: Format workspace (⚠️ missing)
  • Roughly: Show syntax tree (⚠️ missing)

RStudio Integration

Roughly can be used as an external formatter in RStudio. See the RStudio setup guide for detailed instructions.

Configuration

You can configure Roughly via a project-specific roughly.toml file:

[format]
# Number of spaces per indentation level
indent-width = 4
# Automatically detect the appropriate line ending
line-ending = "auto" # "lf" or "cr-lf"

[lint]
# Control the naming convention for variables and parameters
naming-style = "snake_case" # or "camelCase", omit to disable this lint entirely

Experimental Features

Roughly includes several experimental features that can be enabled in the VS Code extension settings or via the CLI:

Name Description
all Enable all experimental features
goto_definition Jump to symbol definitions
goto_references Find all references to a symbol
range_formatting Format selected code ranges
rename Rename symbols
unused Warn about unused variables

Development

See our development documentation.

License

This repository is licensed under The Universal Permissive License Version 1.0.

About

An extremely fast R language server and code formatter, written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •