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>]
Install:
cargo install ron-lspAdd 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 checkIt'll output something like this if there are warnings / errors:
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.
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:
- Parse the
@[crate::models::User]annotation - Find the
Userstruct in your Rust project - Extract field names, types, and documentation
- Provide autocomplete and validation
- Support
Defaulttrait for optional field omission - Provide code actions for inserting either required or missing fields, when applicable
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"),
)#[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,
)Expand a section below for editor-specific instructions.
Make sure you already did cargo install ron-lsp.
Either:
OR
- Grab
.vsixfrom releases
OR
cd vscode-extensionsand package by runningnpm installandvsce package
Then, either ensure 'ron-lsp' is in your PATH or update .vscode/settings.json:
{
...
"ronLsp.serverPath": "/path/to/ron-lsp"
}Make sure you already did cargo install ron-lsp.
Either:
OR
- Grab
.zipfrom releases
OR :
cd jetbrains-plugin
./gradlew buildPluginAnd "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.
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.
See their docs on how to add an LSP, you should be able to follow them for this plugin.
Contributions welcome! This is a foundational implementation that can be extended with more features.
MIT (except altered Rust logo svg, see below)
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.