提交 13d8325a 编写于 作者: M Martin Aeschlimann

[json] update server readme

上级 628bdedf
......@@ -21,6 +21,8 @@ The server implements the following capabilities of the language server protocol
- [Document Symbols](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol) for quick navigation to properties in the document.
- [Document Colors](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentColor) for showing color decorators on values representing colors and [Color Presentation](https://microsoft.github.io/language-server-protocol/specification#textDocument_colorPresentation) for color presentation information to support color pickers. The location of colors is defined by the document's [JSON schema](http://json-schema.org/). All values marked with `"format": "color-hex"` (VSCode specific, non-standard JSON Schema extension) are considered color values. The supported color formats are `#rgb[a]` and `#rrggbb[aa]`.
- [Code Formatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_rangeFormatting) supporting ranges and formatting the whole document.
- [Folding Ranges](https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange) for all folding ranges in the document.
- Semantic Selection for semantic selection for one or multiple cursor positions.
- [Diagnostics (Validation)](https://microsoft.github.io/language-server-protocol/specification#textDocument_publishDiagnostics) are pushed for all open documents
- syntax errors
- structural validation based on the document's [JSON schema](http://json-schema.org/).
......@@ -90,34 +92,33 @@ To find the schema for a given JSON document, the server uses the following mech
- The settings define a schema association based on the documents URL. Settings can either associate a schema URL to a file or path pattern, and they can directly provide a schema.
- Additionally, schema associations can also be provided by a custom 'schemaAssociations' configuration call.
Schemas are identified by URLs. To load the content of a schema, the JSON language server tries to load from that URL or path. The following URL schemas are supported:
- `http`, `https`: Loaded using NodeJS's HTTP support. Proxies can be configured through the settings.
- `file`: Loaded using NodeJS's `fs` support.
- `vscode`: Loaded by an LSP call to the client.
#### Schema associations notification
Schemas are identified by URLs. To load the content of a schema, the JSON language server either tries to load from that URI or path itself, or delegates to the client.
In addition to the settings, schemas associations can also be provided through a notification from the client to the server. This notification is a JSON language server specific, non-standardized, extension to the LSP.
The `initializationOptions.handledSchemaProtocols` initialization option defines which URLs are handled by the server. Requests for all other URIs are send to the client.
Notification:
- method: 'json/schemaAssociations'
- params: `ISchemaAssociations` defined as follows
`handledSchemaProtocols` is part of the initialization options and can't be changed while the server is running.
```ts
interface ISchemaAssociations {
[pattern: string]: string[];
let clientOptions: LanguageClientOptions = {
initializationOptions: {
handledSchemaProtocols: ['file'] // language server should only try to load file URLs
}
...
}
```
- keys: a file names or file path (separated by `/`). `*` can be used as a wildcard.
- values: An array of schema URLs
If `handledSchemaProtocols` is not set, the JSON language server will load the following URLs itself:
- `http`, `https`: Loaded using NodeJS's HTTP support. Proxies can be configured through the settings.
- `file`: Loaded using NodeJS's `fs` support.
#### Schema content request
The schema content for schema URLs that start with `vscode://` will be requested from the client through an LSP request. This request is a JSON language server specific, non-standardized, extension to the LSP.
Requests for schemas with URLs not handled by the server are forwarded to the client through an LSP request. This request is a JSON language server specific, non-standardized, extension to the LSP.
Request:
- method: 'vscode/content'
- params: `string` - The schema URL to request. The server will only ask for URLs that start with `vscode://`
- params: `string` - The schema URL to request.
- response: `string` - The content of the schema with the given URL
#### Schema content change notification
......@@ -125,6 +126,22 @@ Request:
When the client is aware that a schema content has changed, it will notify the server through a notification. This notification is a JSON language server specific, non-standardized, extension to the LSP.
The server will, as a response, clear the schema content from the cache and reload the schema content when required again.
#### Schema associations notification
In addition to the settings, schemas associations can also be provided through a notification from the client to the server. This notification is a JSON language server specific, non-standardized, extension to the LSP.
Notification:
- method: 'json/schemaAssociations'
- params: `ISchemaAssociations` defined as follows
```ts
interface ISchemaAssociations {
[pattern: string]: string[];
}
```
- keys: a file names or file path (separated by `/`). `*` can be used as a wildcard.
- values: An array of schema URLs
Notification:
- method: 'json/schemaContent'
- params: `string` the URL of the schema that has changed.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册