You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceLSPManager{// Start LSP server for a languagestartServer(language: string): Promise<LSPConnection>;// Get existing server connectiongetServer(language: string): LSPConnection|undefined;// Stop serverstopServer(language: string): Promise<void>;// Get server capabilitiesgetCapabilities(language: string): ServerCapabilities;}classLSPManagerImplimplementsLSPManager{privateservers=newMap<string,LSPConnection>();privateconfigs=newMap<string,LSPConfig>();constructor(){// Register default configsthis.configs.set('typescript',{serverPath: require.resolve('typescript-language-server'),serverArgs: ['--stdio'],workspaceConfig: {typescript: {format: {semicolons: true},suggest: {completeFunctionCalls: true}}}});// Add other language configs...}asyncstartServer(language: string): Promise<LSPConnection>{constconfig=this.configs.get(language);if(!config)thrownewError(`No LSP config for ${language}`);constconnection=awaitthis.createServerConnection(config);this.servers.set(language,connection);returnconnection;}}
3.2 Document Manager
interfaceDocumentManager{// Open documentopenDocument(uri: string): Promise<TextDocument>;// Get documentgetDocument(uri: string): TextDocument|undefined;// Apply editsapplyEdit(uri: string,edit: TextEdit): Promise<void>;// Get Monaco modelgetModel(uri: string): monaco.editor.ITextModel;// Validate documentvalidate(uri: string): Promise<Diagnostic[]>;}classDocumentManagerImplimplementsDocumentManager{privatedocuments=newMap<string,TextDocument>();privatemodels=newMap<string,monaco.editor.ITextModel>();asyncopenDocument(uri: string): Promise<TextDocument>{// Create text documentconstdocument=TextDocument.create(uri,'typescript',1,'');// Create Monaco modelconstmodel=monaco.editor.createModel('','typescript');this.documents.set(uri,document);this.models.set(uri,model);returndocument;}}