Skip to content

azdavis/rjsonnet

rjsonnet

An implementation of Jsonnet in Rust, which aims to conform to the spec, and is built with the IDE use-case in mind.

Install

Screenshots

Syntax highlighting, error tolerant parsing, and inline diagnostics

syntax-hl-err-tolerant-diagnostics

Go to (or peek) definition

peek-def

Hover for type and standard library documentation

std-lib

Auto-complete object fields

auto-complete

Signature help

auto-complete

Flow typing

flow typing

Ways to use

VS Code

The primary intended way to use this is via the language server and its official VS Code extension.

Language server

You can also use the language server with any editor that supports language servers. You'll just have to write your own glue code between this server and your editor.

Building from source

  1. Get Rust.
  2. Clone or download the repo.
  3. Enter the repo.

Now you can run things like:

$ cargo build
$ cargo test
$ cargo clippy
$ cargo fmt
$ cargo xtask ci

You can also build the VS Code extension:

  1. Get VS Code.
  2. Get Node.
  3. Ensure other Jsonnet-related extensions like Jsonnet LSP are disabled.
  4. Open the repo in VS Code.
  5. Click "Run and Debug" (by default, the triangular play button with bug on the left).
  6. In the "Run and Debug" sidebar that appears, click the triangular play button by "extension" (you may need to select it from the drop-down). Another VS Code will pop up, with the extension enabled.
  7. Open that VS Code on a folder with Jsonnet files.
  8. Try out the IDE features like inline diagnostics and go-to-def.

Credits

I took a lot of inspiration from the existing Jsonnet LSP extension, but I wanted to try doing it myself, in Rust, from scratch, specifically for IDEs. I had already done so with Standard ML in Millet.

Alternatives

Jsonnet language servers

Some prior art:

These implementations are based off of the Go implementation of Jsonnet.

Rust implementations of Jsonnet

Confusingly, the Python bindings for the former are called rjsonnet.

These implementations are more targeted at implementing the Jsonnet language for evaluating/manifesting it to JSON. This project has some evaluation functionality implemented, but it is mainly intended to be a language server. This makes evaluation of Jsonnet into JSON less of a project goal.

License

Like Rust itself and many other projects in the Rust community, this project is licensed under either the MIT license or the Apache license v2.0, at your option.