ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

LSP-json

by sublimelsp ST3

Schema validation/completions for your JSON and Sublime files

Details

  • 1.20.2
    1.18.14
  • github.​com
  • github.​com
  • 2 weeks ago
  • 1 hour ago
  • 5 years ago

Installs

  • Total 24K
  • Win 8K
  • Mac 8K
  • Linux 7K
Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7
Windows 3 2 2 9 5 5 7 0 0 6 6 6 6 7 12 8 14 8 4 1 7 10 5 6 15 7 7 5 1 14 8 10 3 12 4 11 14 4 10 7 9 9 7 13 8 9
Mac 0 4 0 6 3 10 4 0 0 7 4 8 8 7 7 9 3 6 7 3 3 5 7 5 6 6 7 4 5 6 6 3 6 4 6 2 4 9 5 2 8 8 3 9 5 7
Linux 2 2 0 7 7 4 9 0 0 7 9 2 4 6 5 4 4 10 4 2 7 5 6 2 7 9 6 2 8 8 1 5 4 6 1 5 4 6 10 9 5 7 6 8 9 6

Readme

Source
raw.​githubusercontent.​com

LSP-json

JSON support for Sublime's LSP plugin.

Uses VSCode JSON Language Server to provide validation, formatting and other features for JSON files. See linked repository for more information.

Installation

  • Install LSP and LSP-json from Package Control.
  • Restart Sublime.

Configuration

Open configuration file using command palette with Preferences: LSP-json Settings command or opening it from the Sublime menu (Preferences > Package Settings > LSP > Servers > LSP-json).

For users of PackageDev

The PackageDev package implements features that provide completions and tooltips when editing the Sublime settings files, which overlaps and conflicts with functionality provided by this package. To take advantage of the strict schemas that this package provides, disable corresponding functionality in PackageDev by opening Preferences: PackageDev Settings from the Command Palette and set the following settings on the right side:

{
  "settings.auto_complete": false,
  "settings.tooltip": false
}

Color Provider

The JSON-Language-Server implements a color provider that adds color decorators next to values representing colors in JSON files. If you are using a color plugin like ColorHelper or Color Highlight you may wish to disable this feature. To disable it open the LSP-json Settings as described above and add the following settings on the right side:

{
  "disabled_capabilities": {
    "colorProvider": true
  }
}

Custom schemas

To load manually created schemas, add those to userSchemas configuration in the settings file. See more information in the comments there.

The custom schema entry needs to look like:

{
  "fileMatch": [
    "/my-file.json"
  ],
  "uri": "./my-file-schema.json",
}

The fileMatch is an array of file patterns to match against when resolving JSON files to schemas. * and ** can be used as a wildcard. Exclusion patterns can also be defined and start with !. A file matches when there is at least one matching pattern and the last matching pattern is not an exclusion pattern.

The uri is a URI or a file path to a schema. Can be a relative path (starting with ./) when defined in a project settings and in that case will be resolved relative to the first project folder.

Schemas contributed by Packages

Sublime Text packages can provide schemas for its own settings, or contribute to global ST settings or other configuration files (for example *.sublime-project files).

This is accomplished by including a sublime-package.json file in the package (location doesn't matter) and defining schemas within it. Any changes made to the schemas are automatically applied to matching files so there is no need to restart the server or ST.

Here is a an example of three different schemas defined in one sublime-package.json file:

{
  "contributions": {
    "settings": [
      {
        // Schema for MyPackage configuration.
        "file_patterns": ["/MyPackage.sublime-settings"],
        "schema": {
          "properties": {
            "my_cool_setting": {
              "type": "string",
              "default": "yes",
              "enum": ["yes", "no"],
              "markdownDescription": "Decides whether something is `on` or `off`."
            }
          },
          "additionalProperties": false,
        }
      },
      {
        // Schema to extend global ST Preferences.
        "file_patterns": ["/Preferences.sublime-settings"],
        "schema": {
          "properties": {
            "my_cool_setting": {
              // Reuses definition from the pattern-less schema defined below.
              "$ref": "sublime://settings/foo/base#/definitions/ReuseMe"
            }
          },
        }
      },
      {
        // Pattern-less schema (note that "file_patterns" is missing).
        // Can be added for the purpose of referencing it (or its definitions) from another schema.
        // Pattern-less schema must define an "$id" to be able to refer to it from other schemas.
        // It's recommended to assign URIs like "sublime://settings/foo/base" for "$id".
        "schema": {
          "$id": "sublime://settings/foo/base"
          "definitions": {
            "ReuseMe": {
              "type": "string",
              "default": "no",
              "enum": ["yes", "no"],
              "markdownDescription": "Decides whether something is `on` or `off`."
            }
          },
        }
      }
    ]
  }
}