Thanks to visit codestin.com
Credit goes to github.com

Skip to content

An LSP and CLI for RON files that provides autocomplete, diagnostics, go to definition, code actions, and hover support based on Rust type annotations

License

Notifications You must be signed in to change notification settings

jasonjmcghee/ron-lsp

Repository files navigation

ron-lsp

Crates.io License Visual Studio Marketplace Badge JetBrains Plugin Version

Type validation for .ron files (in or out of the ide)

An LSP for RON files that provides autocomplete, diagnostics, go to definition, code actions, and hover support based on Rust type annotations. It can also be used to check in bulk via CLI, optionally with a path. ron-lsp check [<path>]

Screenshot 2025-10-24 at 9 59 22 AM

Getting started

Install:

cargo install ron-lsp

Add comment annotations to the top of .ron files like /* @[crate::models::User] */.

And then use the cli (from a rust project working directory):

ron-lsp check

It'll output something like this if there are warnings / errors:

Screenshot 2025-10-24 at 10 02 35 AM

You can optionally pass a file or folder. (e.g. ron-lsp check crates/sub-crate - it will recursively check all .ron files from that point.)

It will use the nearest Cargo.toml starting from the resolved .ron file.

Usage

Type Annotation Format

At the top of your RON file, add a block comment with the type annotation:

/* @[crate::models::User] */

User(
    id: 1,
    name: "Alice",
    email: "[email protected]",
    age: 30,
)

The LSP will:

  1. Parse the @[crate::models::User] annotation
  2. Find the User struct in your Rust project
  3. Extract field names, types, and documentation
  4. Provide autocomplete and validation
  5. Support Default trait for optional field omission
  6. Provide code actions for inserting either required or missing fields, when applicable

Example

src/models/user.rs:

pub struct User {
    pub id: u32,
    pub name: String,
    pub email: String,
    pub age: u32,
    pub bio: Option<String>,
}

data/users.ron:

/* @[crate::models::User] */

User(
    id: 1,
    name: "Alice",
    email: "[email protected]",
    age: 30,
    bio: Some("Software developer"),
)

Example with Defaults

#[derive(Default, Serialize, Deserialize)]
pub struct Config {
    pub host: String,
    pub port: u16,
    pub max_connections: u32,
    pub debug: bool,
    pub api_key: Option<String>,
    pub allowed_origins: Vec<String>,
}
/* @[crate::models::Config] */
Config(
    // This Config struct has #[derive(Default)]
    // So we can omit fields and they will use their default values
    // The LSP should NOT show warnings for missing fields
    port: 8080,
    debug: true,
)
Screenshot 2025-10-24 at 5 52 13 PM

Editor Integration

Expand a section below for editor-specific instructions.

VSCode

Make sure you already did cargo install ron-lsp.

Either:

OR

OR

  • cd vscode-extensions and package by running npm install and vsce package

Then, either ensure 'ron-lsp' is in your PATH or update .vscode/settings.json:

{
  ...
  "ronLsp.serverPath": "/path/to/ron-lsp"
}

Visual Studio Marketplace Badge

JetBrains

Make sure you already did cargo install ron-lsp.

Either:

OR

OR :

cd jetbrains-plugin
./gradlew buildPlugin

And "Install Plugin from Disk" and choose the zip.

Then, either ensure 'ron-lsp' is in your PATH or update "Server path" in Settings > Tools > RON LSP.

JetBrains Plugin Version

Neovim

Make sure you already did cargo install ron-lsp.

Ensure you already have nvim-lspconfig.

Note: If you don't want ron-lsp in your path, replace with the absolute path.

Add ron.lua to ~/.config/nvim/lua/plugins/ron.lua.

Other editors (e.g. Zed / Helix)

See their docs on how to add an LSP, you should be able to follow them for this plugin.

Contributing

Contributions welcome! This is a foundational implementation that can be extended with more features.

License

MIT (except altered Rust logo svg, see below)

Attribution

The logo used in the Jetbrains plugin is a colorized version of the Rust logo which is CC-BY 4.0. See Rust logo specific trademark policy for additional details.