Separate json and jsonc (fixes #3641, fixes #26830, fixes #19992)

This commit is contained in:
Martin Aeschlimann
2017-11-27 10:29:30 +01:00
parent 30296f6e61
commit 0c2de00043
5 changed files with 38 additions and 16 deletions

View File

@@ -6,7 +6,7 @@
import * as path from 'path';
import { workspace, languages, ExtensionContext, extensions, Uri, TextDocument, ColorInformation, Color, ColorPresentation } from 'vscode';
import { workspace, languages, ExtensionContext, extensions, Uri, TextDocument, ColorInformation, Color, ColorPresentation, LanguageConfiguration } from 'vscode';
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType, DidChangeConfigurationNotification } from 'vscode-languageclient';
import TelemetryReporter from 'vscode-extension-telemetry';
import { ConfigurationFeature } from 'vscode-languageclient/lib/configuration.proposed';
@@ -67,7 +67,7 @@ export function activate(context: ExtensionContext) {
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('server', 'out', 'jsonServerMain.js'));
// The debug options for the server
let debugOptions = { execArgv: ['--nolazy', '--inspect=6004'] };
let debugOptions = { execArgv: ['--nolazy', '--inspect'] };
// If the extension is launch in debug mode the debug server options are use
// Otherwise the run options are used
@@ -76,7 +76,7 @@ export function activate(context: ExtensionContext) {
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
};
let documentSelector = ['json'];
let documentSelector = ['json', 'jsonc'];
// Options to control the language client
let clientOptions: LanguageClientOptions = {
@@ -159,13 +159,15 @@ export function activate(context: ExtensionContext) {
}));
});
languages.setLanguageConfiguration('json', {
let languageConfiguration: LanguageConfiguration = {
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/,
indentationRules: {
increaseIndentPattern: /^.*(\{[^}]*|\[[^\]]*)$/,
decreaseIndentPattern: /^\s*[}\]],?\s*$/
}
});
};
languages.setLanguageConfiguration('json', languageConfiguration);
languages.setLanguageConfiguration('jsonc', languageConfiguration);
}
function getSchemaAssociation(context: ExtensionContext): ISchemaAssociations {