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

Commit

Permalink
Add flag to disable gopls highlighting (#2833)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikraobr authored and ramya-rao-a committed Oct 20, 2019
1 parent da16ae7 commit ccd44d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
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

0 comments on commit ccd44d9

Please sign in to comment.