Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
add toml configuration to support schema. fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
bungcip committed Nov 12, 2016
1 parent 2a2d41e commit cda0399
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
54 changes: 47 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,60 @@
"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 ./",
"compile": "tsc -watch -p ./",
"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"
},
Expand All @@ -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"
}
}
}
10 changes: 5 additions & 5 deletions server/tomlServerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ let languageService = getTomlLanguageService({

// The settings interface describes the server relevant settings part
interface Settings {
json: {
toml: {
schemas: JSONSchemaSettings[];
};
http: {
Expand All @@ -224,15 +224,15 @@ 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.
connection.onDidChangeConfiguration((change) => {
var settings = <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();
});

Expand All @@ -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;
Expand Down

0 comments on commit cda0399

Please sign in to comment.