add activationEvents

This commit is contained in:
chemzqm 2018-09-08 18:32:16 +08:00
parent cef7eaffd9
commit ae46f08fff
2 changed files with 16 additions and 20 deletions

View file

@ -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",

View file

@ -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<void> {
this.clientHost = new TypeScriptServiceClientHost(this.descriptions)
this.disposables.push(this.clientHost)
Object.defineProperty(this, 'state', {
get: () => {
return this.clientHost.serviceClient.state