7

If you read the documentation for lsp-mode-lsp-json here, this is the section that deals with setting schemas:

Available configurations

lsp-json-schemas

Default: nil

Associate schemas to JSON files in the current project

I have no idea how to use that. Is there an example somewhere?

lsp-json-schemas is a variable defined in ‘lsp-json.el’.

Its value is nil

Documentation:

Associate schemas to JSON files in the current project

You can customize this variable.

This variable was introduced, or its default value was changed, in version 6.3 of the lsp-mode package.

I googled, but can't find an example of how to use this variable anywhere.

Pieter Breed
  • 201
  • 1
  • 4

3 Answers3

3

I still don't know how to use the lsp-json-schemas variable, but with this mode properly activated in emacs you can add a top-level $schema property to the object you are presumably editing in the file and the auto-completions and other features will kick in.

{
   "$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/master/schema.json",
   "basics": { "name": "Pieter", "email": "some@email.com", ... },
   ...
}
Pieter Breed
  • 201
  • 1
  • 4
0

Have you tried something like this?:

(setq lsp-json-schemas '((json-mode . "/path/to/schema/SchemaJSONFile.json")))

According to the inline documentation this variable must be a repeat alist.

frperies
  • 1
  • 1
0

According to this comment, it should be:

(setq lsp-json-schemas
 `[(:fileMatch ["foo.json" "*.morefoo.json"] :url "http://json.schemastore.org/foo")])
vmiheer
  • 35
  • 4