Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Add flag to disable gopls highlighting #2833

Merged
merged 2 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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."
},
Expand Down Expand Up @@ -1609,4 +1615,4 @@
]
}
}
}
}
11 changes: 9 additions & 2 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -50,6 +50,7 @@ interface LanguageServerConfig {
workspaceSymbols: boolean;
implementation: boolean;
documentLink: boolean;
highlight: boolean;
};
checkForUpdates: boolean;
}
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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()));
}
Expand Down Expand Up @@ -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']
};
Expand Down