Skip to content

Commit

Permalink
wip: LanguageServiceContext
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Apr 25, 2023
1 parent bc678fa commit 298ef29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
15 changes: 7 additions & 8 deletions packages/language-server/src/common/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type * as ts from 'typescript/lib/tsserverlibrary';
import * as html from 'vscode-html-languageservice';
import * as vscode from 'vscode-languageserver';
import { URI, Utils } from 'vscode-uri';
import { FileSystem, LanguageServerPlugin, LanguageServiceContext, ServerMode } from '../types';
import { FileSystem, LanguageServerPlugin, ServerMode } from '../types';
import { loadConfig } from './utils/serverConfig';
import { createUriMap } from './utils/uriMap';
import { WorkspaceContext } from './workspace';
Expand Down Expand Up @@ -115,15 +115,14 @@ export async function createProject(context: ProjectContext) {
return '';
},
};
const lsCtx: LanguageServiceContext = {
project: context,
options,
sys,
host: languageServiceHost,
};
for (const plugin of context.workspace.workspaces.plugins) {
if (plugin.resolveConfig) {
config = plugin.resolveConfig(config, lsCtx);
config = plugin.resolveConfig(config, {
project: context,
options,
sys,
host: languageServiceHost,
});
}
}
languageService = embeddedLS.createLanguageService(options, context.documentRegistry);
Expand Down
14 changes: 6 additions & 8 deletions packages/language-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,18 @@ export interface RuntimeEnvironment {
};
}

export interface LanguageServiceContext {
project: ProjectContext;
options: ServiceOptions;
host: embedded.LanguageServiceHost;
sys: FileSystem;
}

export interface LanguageServerPlugin {
(initOptions: LanguageServerInitializationOptions, modules: { typescript?: typeof import('typescript/lib/tsserverlibrary'); }): {
extraFileExtensions?: ts.FileExtensionInfo[];
watchFileExtensions?: string[];
resolveConfig?(
config: Config,
ctx: LanguageServiceContext | undefined,
ctx: {
project: ProjectContext;
options: ServiceOptions;
host: embedded.LanguageServiceHost;
sys: FileSystem;
} | undefined,
): Config;
onInitialized?(getLanguageService: (uri: string) => Promise<LanguageService | undefined>, env: RuntimeEnvironment): void;
};
Expand Down

0 comments on commit 298ef29

Please sign in to comment.