JSON-LD Language Server Demo

Simple demo application that shows the power and usefulness of adding LSP support to JSON-LD.

Editor

Loading editor...

{
  "@context": "https://raw.githubusercontent.com/json-ld/json-ld.org/main/contexts/person.jsonld",
  "@id": "http://example.com/me",
  "knows": {"@id": "http://example.com/you"}
}

The editor will provide autocompletion on properties defined in the linked person.jsonld context. This will be done very greedily but still a productivity boost is present.

Autocompletion on defined identifiers can be issued by typing @.

Syntax errors are also gathered by the language server.

This editor is powered by the json-ld. The editor itself uses the codemirror components. A thin wrapper links the codemirror editor with the LSP. The LSP itself is compiled to WebAssembly and loaded on the page.

Note that codemirror does not natively support LSPs, the LSP features you see here are coded with a small wrapper layer, but features like semantic highlighting are not supported for this reason.

Screencast

Because of the double blind requirements I'm not able to let you integrate the LSP with your local editors, this however does give the best experience. To help you better understand what it looks like in a real editor, I created a screencast of the LSP in VSCode. Screencast

Editor compatibility

The main benifit of a LSP is that it can be installed on many platforms. NeoVim only requires some configuration because the Language Server protocol is native to the editor. Other editors like VSCode require a little bit more work to, to create an extension for each supported Language Server, this is considered to be a thin wrapper.

VS Code

Installing the language server for VS Code is as simple as installing the correct extensions. This extension is called redacted lsp and can be found on redacted.

Creating the extension is done with special care to make it a, so called, web extension. This makes it also possible to use this extension on online VS code instances like vscode.dev.

NeoVim

NeoVim has native support for Language Servers. NeoVim starts up a binary and communicates with it via stdin and stdout. To enable the JSON-LD LSP, please install it with cargo. The NeoVim lsp integration has a dependency on the LSP binary.

Lua configuration
#  Add a config to lspconfig.configs
local configs = require("lspconfig.configs")

configs.jsonld = {
  default_config = {
    cmd = { 'jsonld-language-server' },
    filetypes = { 'jsonld' },
    root_dir = require("lspconfig.util")
      .find_git_ancestor,
    single_file_support = true,
    init_options = {},
  }
}

# Start the LSP
local lspconfig = require("lspconfig")

lspconfig.jsonld.setup {
  on_attach = M.on_attach,
  capabilities = M.capabilities,
}