Skip to content

Commit e104417

Browse files
committed
(GH-335) Add option to disable language server
This commit surfaces an option to disable loading the Puppet Language Server, while still allowing the features that do not require a language server. The first time this option is set, the user will be presented with a message explainging what they turned off with an option to not show this message again. The message won't be shown next time if the user presses the button.
1 parent 40e2ee1 commit e104417

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/extension.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { OutputChannelLogger } from './logging/outputchannel';
1919
import { PuppetCommandStrings } from './messages';
2020
import { PuppetStatusBar } from './PuppetStatusBar';
2121
import { ISettings, legacySettings, settingsFromWorkspace } from './settings';
22-
import { Reporter } from './telemetry/telemetry';
22+
import { Reporter, reporter } from './telemetry/telemetry';
2323

2424
const langID = 'puppet'; // don't change this
2525
let extContext: vscode.ExtensionContext;
@@ -43,6 +43,12 @@ export function activate(context: vscode.ExtensionContext) {
4343
statusBar = new PuppetStatusBar(langID, context, logger);
4444
configSettings = new ConnectionConfiguration();
4545

46+
if(settings.editorService.enable === false){
47+
notifyEditorServiceDisabled(extContext);
48+
reporter.sendTelemetryEvent('editorServiceDisabled');
49+
return;
50+
}
51+
4652
if(checkInstallDirectory(configSettings, logger) === false){
4753
// If this returns false, then we needed a local directory
4854
// but did not find it, so we should abort here
@@ -172,3 +178,26 @@ async function notifyOnNewExtensionVersion(context: vscode.ExtensionContext) {
172178
context.globalState.update(suppressUpdateNotice, true);
173179
}
174180
}
181+
182+
async function notifyEditorServiceDisabled(context: vscode.ExtensionContext) {
183+
const suppressEditorServicesDisabled = 'suppressEditorServicesDisabled';
184+
const dontShowAgainNotice = "Don't show again";
185+
186+
if (context.globalState.get(suppressEditorServicesDisabled, false)) {
187+
return;
188+
}
189+
190+
const result = await vscode.window.showInformationMessage(
191+
`Puppet Editor Services has been disabled. While syntax highlighting and grammar detection will still work, intellisense and other advanced features will not.`,
192+
{ modal: false },
193+
{ title: dontShowAgainNotice }
194+
);
195+
196+
if (result === undefined) {
197+
return;
198+
}
199+
200+
if (result.title === dontShowAgainNotice) {
201+
context.globalState.update(suppressEditorServicesDisabled, true);
202+
}
203+
}

0 commit comments

Comments
 (0)