From cda0399179cc9b57542a4fff2212b0b71c66ef64 Mon Sep 17 00:00:00 2001 From: Gigih Aji Ibrahim Date: Sun, 13 Nov 2016 02:45:11 +0700 Subject: [PATCH] add toml configuration to support schema. fix #2 --- package.json | 54 ++++++++++++++++++++++++++++++++++------ server/tomlServerMain.ts | 10 ++++---- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 3709cef..d29d9b6 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,49 @@ "scopeName": "source.toml", "path": "./syntaxes/TOML.tmLanguage" } - ] + ], + "configuration": { + "id": "toml", + "order": 30, + "type": "object", + "title": "TOML", + "properties": { + "toml.schemas": { + "type": "array", + "description": "Associate schemas to TOML files in the current project", + "items": { + "type": "object", + "default": { + "fileMatch": [ + "{{/myfile}}" + ], + "url": "{{schemaURL}}" + }, + "properties": { + "url": { + "type": "string", + "default": "/user.schema.json", + "description": "A URL to a schema or a relative path to a schema in the current directory" + }, + "fileMatch": { + "type": "array", + "items": { + "type": "string", + "default": "MyFile.toml", + "description": "A file pattern that can contain '*' to match against when resolving TOML files to schemas." + }, + "minItems": 1, + "description": "An array of file patterns to match against when resolving TOML files to schemas." + }, + "schema": { + "$ref": "http://json-schema.org/draft-04/schema#", + "description": "The schema definition for the given URL. The schema only needs to be provided to avoid accesses to the schema URL." + } + } + } + } + } + } }, "scripts": { "vscode:prepublish": "tsc -p ./", @@ -58,11 +100,10 @@ "postinstall": "node ./node_modules/vscode/bin/install" }, "dependencies": { - "ajv": "^4.8.2", "request-light": "^0.1.0", "toml": "^2.3.0", - "vscode-languageclient": "^2.6.0", - "vscode-languageserver": "^2.6.0", + "vscode-languageclient": "^2.6.2", + "vscode-languageserver": "^2.6.1", "vscode-json-languageservice": "^1.1.7", "vscode-nls": "^2.0.1" }, @@ -71,7 +112,6 @@ "vscode": "^1.0.3", "mocha": "^3.1.2", "@types/node": "^6.0.46", - "@types/mocha": "^2.2.32", - "@types/ajv": "^0.0.3" + "@types/mocha": "^2.2.32" } -} +} \ No newline at end of file diff --git a/server/tomlServerMain.ts b/server/tomlServerMain.ts index 50b9f78..4903027 100644 --- a/server/tomlServerMain.ts +++ b/server/tomlServerMain.ts @@ -209,7 +209,7 @@ let languageService = getTomlLanguageService({ // The settings interface describes the server relevant settings part interface Settings { - json: { + toml: { schemas: JSONSchemaSettings[]; }; http: { @@ -224,7 +224,7 @@ interface JSONSchemaSettings { schema?: JSONSchema; } -let jsonConfigurationSettings: JSONSchemaSettings[] = void 0; +let tomlConfigurationSettings: JSONSchemaSettings[] = void 0; let schemaAssociations: ISchemaAssociations = void 0; // The settings have changed. Is send on server activation as well. @@ -232,7 +232,7 @@ connection.onDidChangeConfiguration((change) => { var settings = change.settings; configureHttpRequests(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL); - jsonConfigurationSettings = settings.json && settings.json.schemas; + tomlConfigurationSettings = settings.toml && settings.toml.schemas; updateConfiguration(); }); @@ -258,8 +258,8 @@ function updateConfiguration() { } } } - if (jsonConfigurationSettings) { - jsonConfigurationSettings.forEach(schema => { + if (tomlConfigurationSettings) { + tomlConfigurationSettings.forEach(schema => { let uri = schema.url; if (!uri && schema.schema) { uri = schema.schema.id;