Skip to content

Commit

Permalink
Refactor to setupConfigure for vuejs#2388
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo930021 committed Oct 16, 2020
1 parent 78ae955 commit b6c081a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions server/src/services/vls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export class VLS {
}

async init(params: InitializeParams) {
const config: VLSFullConfig = params.initializationOptions?.config
? _.merge(getDefaultVLSConfig(), params.initializationOptions.config)
: getDefaultVLSConfig();
const config: VLSFullConfig = this.getFullConfig(params.initializationOptions?.config);

const workspacePath = params.rootPath;
if (!workspacePath) {
Expand Down Expand Up @@ -127,21 +125,26 @@ export class VLS {
this.dispose();
});

this.configure(config);
await this.setupConfigure(config);
}

listen() {
this.lspConnection.listen();
}

private getFullConfig(original: unknown): VLSFullConfig {
return original ? _.merge(getDefaultVLSConfig(), original) : getDefaultVLSConfig();
}

public async setupConfigure(config: VLSFullConfig) {
this.configure(config);

await this.setupDynamicFormatters(config);
}

private setupConfigListeners() {
this.lspConnection.onDidChangeConfiguration(async ({ settings }: DidChangeConfigurationParams) => {
if (settings) {
this.configure(settings);

// onDidChangeConfiguration will fire for Language Server startup
await this.setupDynamicFormatters(settings);
}
await this.setupConfigure(this.getFullConfig(settings));
});

this.documentService.getAllDocuments().forEach(this.triggerValidation);
Expand Down

0 comments on commit b6c081a

Please sign in to comment.