jsonvetdocsEditors

playgroundthis page on GitHub

Editors

jsonvet lsp is a language server: it speaks the Language Server Protocol on standard input and output, so any editor that has a client for it can show jsonvet's problems as you type. It offers:

Only files on disk are checked (file: URIs), since the settings are picked by the file's path. A file with a syntax error is not formatted. Positions are counted in UTF-16 code units, as the protocol asks by default, or in bytes when the editor offers UTF-8. jsonvet lsp takes no other options but --help and --version; --stdio is accepted, as some clients pass it. A file named lsp needs ./lsp, as fmt does.

The search for jsonvet.toml stops at the workspace folder that holds the file, unless a nearer .git directory stops it first. The server takes the folders from the editor's initialize request (workspaceFolders, else rootUri) and follows the folders the editor adds and removes later. For a file outside those folders, including when no folder is open, the search stops at the file's own folder.

When the editor can watch files for the server, the server asks it to watch jsonvet.toml, pyproject.toml, the user's own config file and the local schemas used by open files. It checks every open file again when one changes. Schema watches follow the files as they open, change schemas and close. Other clients can send workspace/didChangeWatchedFiles for those files themselves.

The server checks the whole file on each change without waiting for typing to stop. Changes that arrive while a check runs are checked once, at the latest text.

VS Code

The extension in editors/vscode is a thin client for jsonvet lsp. Its README says how it shares JSON and JSONC files with VS Code's own JSON validation.

The extension is not on the Marketplace yet. Build it with just vsix from the repository root, then install it:

code --install-extension editors/vscode/jsonvet-<version>.vsix

Neovim

With Neovim 0.11 or later, in init.lua:

vim.lsp.config("jsonvet", {
  cmd = { "jsonvet", "lsp" },
  filetypes = { "json", "jsonc", "json5", "jsonl" },
  root_markers = { "jsonvet.toml", ".git" },
})
vim.lsp.enable("jsonvet")

vim.lsp.buf.format() formats the file, or the selection in visual mode.

Helix

In languages.toml:

[language-server.jsonvet]
command = "jsonvet"
args = ["lsp"]

[[language]]
name = "json"
language-servers = ["jsonvet"]

[[language]]
name = "jsonc"
language-servers = ["jsonvet"]

[[language]]
name = "json5"
language-servers = ["jsonvet"]

Listing jsonvet alone replaces Helix's default JSON server, so problems do not show twice. Helix treats .jsonl files as json, so they are covered. It has no JWCC language.

Other editors

Run jsonvet lsp as the server command for JSON, JSONC, JSON5 and JSON Lines files, over standard input and output.