From ae46f08fff87e51947c9d601844406fa6a45908a Mon Sep 17 00:00:00 2001 From: chemzqm Date: Sat, 8 Sep 2018 18:32:16 +0800 Subject: [PATCH] add activationEvents --- package.json | 32 ++++++++++++++------------------ src/server/index.ts | 4 ++-- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 9355b4a..db3b8e2 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,21 @@ "build": "tsc -p tsconfig.json", "prepare": "yarn clean && yarn build" }, + "activationEvents": [ + "onLanguage:javascript", + "onLanguage:javascriptreact", + "onLanguage:typescript", + "onLanguage:typescriptreact", + "onLanguage:jsx-tags", + "onCommand:typescript.reloadProjects", + "onCommand:javascript.reloadProjects", + "onCommand:javascript.goToProjectConfig", + "onCommand:typescript.goToProjectConfig", + "onCommand:typescript.openTsServerLog", + "onCommand:tsserver.watchBuild", + "onLanguage:jsonc" + ], "contributes": { - "activationEvents": [ - "*" - ], "commands": [ { "title": "Reload current project", @@ -32,21 +43,6 @@ "category": "TSServer", "command": "tsserver.goToProjectConfig" }, - { - "title": "Restart tsserver.", - "category": "TSServer", - "command": "tsserver.restart" - }, - { - "title": "Format current buffer.", - "category": "TSServer", - "command": "tsserver.format" - }, - { - "title": "Orgnize imports of current buffer.", - "category": "TSServer", - "command": "tsserver.organizeImports" - }, { "title": "Run `tsc --watch` for current project in terminal buffer.", "category": "TSServer", diff --git a/src/server/index.ts b/src/server/index.ts index 07e6fd6..75c4964 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -35,8 +35,6 @@ export default class TsserverService implements IServiceProvider { this.selector = this.descriptions.reduce((arr, c) => { return arr.concat(c.modeIds) }, []) - this.clientHost = new TypeScriptServiceClientHost(this.descriptions) - this.disposables.push(this.clientHost) } public get config(): WorkspaceConfiguration { @@ -44,6 +42,8 @@ export default class TsserverService implements IServiceProvider { } public start(): Promise { + this.clientHost = new TypeScriptServiceClientHost(this.descriptions) + this.disposables.push(this.clientHost) Object.defineProperty(this, 'state', { get: () => { return this.clientHost.serviceClient.state