add simple install notification

This commit is contained in:
Daniel Hung 2020-02-20 14:43:28 -08:00
parent a4c48ecf73
commit 77733c8d88
2 changed files with 25 additions and 0 deletions

View File

@ -69,6 +69,11 @@
"default": false,
"description": "Displays JSON data used by a view and also updates sample.html with the last rendered HTML."
},
"kite.installKiteEngineOnStartup": {
"type": "boolean",
"default": true,
"description": "Offer to install Kite Engine on editor startup if it's not already installed."
},
"kite.startKiteEngineOnStartup": {
"type": "boolean",
"default": true,

View File

@ -388,6 +388,7 @@ const Kite = {
this.supportedExtensions = [];
this.shown = {};
this.disposables = [];
this.attemptedToInstallKite = false;
this.attemptedToStartKite = false;
delete this.shownNotifications;
delete this.lastState;
@ -482,6 +483,25 @@ const Kite = {
);
break;
case KiteAPI.STATES.UNINSTALLED:
if (
!this.attemptedToInstallKite
&& vscode.workspace.getConfiguration("kite").installKiteEngineOnStartup
) {
const msg = "Kite requires the Kite Engine backend to provide completions and documentation.";
const ok = "Install Kite Engine";
const hide = "Don't show this again";
metrics.track("vscode_kite_installer_notification_shown");
vscode.window.showInformationMessage(msg, ok, hide).then(item => {
if (item === ok) {
opn("https://kite.com/download?utm_source=vscode")
metrics.track("vscode_kite_installer_download_opened");
}
if (item === hide) {
config.update("installKiteEngineOnStartup", false, true);
}
});
this.attemptedToInstallKite = true;
}
if (
this.shown[state] ||
(vscode.window.activeTextEditor &&