client/vscode/src/extension.ts in yoda-language-server-0.7.2 vs client/vscode/src/extension.ts in yoda-language-server-0.8.0

- old
+ new

@@ -1,42 +1,26 @@ -'use strict'; +import { ExtensionContext, Disposable } from 'vscode' +import { isLanguageServerInstalled, promptForInstallTool } from './install-tools' +import { configureLanguageServer } from './language-server' -import * as path from 'path'; +let disposable: Disposable -// The module 'vscode' contains the VS Code extensibility API -// Import the module and reference it with the alias vscode in your code below -import * as vscode from 'vscode'; -import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient'; -import { worker } from 'cluster'; -import { workspace } from 'vscode'; - // this method is called when your extension is activated // your extension is activated the very first time the command is executed -export function activate(context: vscode.ExtensionContext) { +export async function activate(context: ExtensionContext) { // Use the console to output diagnostic information (console.log) and errors (console.error) // This line of code will only be executed once when your extension is activated - console.log('Congratulations, your extension "yoda" is now active!'); + // console.log('Congratulations, your extension "yoda" is now active!'); - let execOptions = { - command: 'yoda', - args: ['server'], + if (!isLanguageServerInstalled()) { + await promptForInstallTool() } - let serverOptions : ServerOptions = { - run: execOptions, - debug: execOptions, - } + const languageServer = configureLanguageServer() - let clientOptions : LanguageClientOptions = { - documentSelector: [{ scheme: 'file', language: 'ruby' }], - synchronize: { - configurationSection: 'yoda', - fileEvents: workspace.createFileSystemWatcher('**/.rb'), - } - } - - let disposable = new LanguageClient('yoda', 'Yoda', serverOptions, clientOptions).start(); + disposable = languageServer.start() } // this method is called when your extension is deactivated export function deactivate() { + disposable?.dispose() }