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.

3 Answers 3

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": "[email protected]", ... },
   ...
}
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.

0

According to this comment, it should be:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.