diff --git a/package.json b/package.json index f60f8c44e..32484eefb 100644 --- a/package.json +++ b/package.json @@ -1145,6 +1145,11 @@ "type": "boolean", "default": false, "description": "If true, the language server will accept incremental document synchronization." + }, + "highlight": { + "type": "boolean", + "default": true, + "description": "If true, the language server will be used to highlighting selected text." } }, "default": { @@ -1160,7 +1165,8 @@ "workspaceSymbols": true, "findReferences": true, "diagnostics": true, - "documentLink": true + "documentLink": true, + "highlight": true }, "description": "Use this setting to enable/disable experimental features from the language server." }, @@ -1609,4 +1615,4 @@ ] } } -} +} \ No newline at end of file diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts index d51c41f07..7d4a9958e 100644 --- a/src/goLanguageServer.ts +++ b/src/goLanguageServer.ts @@ -12,7 +12,7 @@ import util = require('util'); import WebRequest = require('web-request'); import path = require('path'); import cp = require('child_process'); -import { FormattingOptions, HandleDiagnosticsSignature, LanguageClient, ProvideCompletionItemsSignature, ProvideDefinitionSignature, ProvideDocumentFormattingEditsSignature, ProvideDocumentLinksSignature, ProvideDocumentSymbolsSignature, ProvideHoverSignature, ProvideReferencesSignature, ProvideRenameEditsSignature, ProvideSignatureHelpSignature, ProvideWorkspaceSymbolsSignature, RevealOutputChannelOn } from 'vscode-languageclient'; +import { FormattingOptions, HandleDiagnosticsSignature, LanguageClient, ProvideCompletionItemsSignature, ProvideDefinitionSignature, ProvideDocumentFormattingEditsSignature, ProvideDocumentLinksSignature, ProvideDocumentSymbolsSignature, ProvideHoverSignature, ProvideReferencesSignature, ProvideRenameEditsSignature, ProvideSignatureHelpSignature, ProvideWorkspaceSymbolsSignature, RevealOutputChannelOn, ProvideDocumentHighlightsSignature } from 'vscode-languageclient'; import { ProvideImplementationSignature } from 'vscode-languageclient/lib/implementation'; import { ProvideTypeDefinitionSignature } from 'vscode-languageclient/lib/typeDefinition'; import { GoDefinitionProvider } from './goDeclaration'; @@ -50,6 +50,7 @@ interface LanguageServerConfig { workspaceSymbols: boolean; implementation: boolean; documentLink: boolean; + highlight: boolean; }; checkForUpdates: boolean; } @@ -177,6 +178,12 @@ export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) { return null; } return next(document, token); + }, + provideDocumentHighlights: (document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, next: ProvideDocumentHighlightsSignature) => { + if (!config.features.highlight) { + return null; + } + return next(document, position, token); } } } @@ -195,7 +202,6 @@ export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) { ctx.subscriptions.push(provider); ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(GO_MODE, provider, '.', '\"')); } - if (!config.features.format || !capabilities.documentFormattingProvider) { ctx.subscriptions.push(vscode.languages.registerDocumentFormattingEditProvider(GO_MODE, new GoDocumentFormattingEditProvider())); } @@ -309,6 +315,7 @@ export function parseLanguageServerConfig(): LanguageServerConfig { workspaceSymbols: goConfig['languageServerExperimentalFeatures']['workspaceSymbols'], implementation: goConfig['languageServerExperimentalFeatures']['implementation'], documentLink: goConfig['languageServerExperimentalFeatures']['documentLink'], + highlight: goConfig['languageServerExperimentalFeatures']['highlight'], }, checkForUpdates: goConfig['useGoProxyToCheckForToolUpdates'] };