WIP lsp-manager effort 4

This commit is contained in:
itdominator 2025-07-13 02:59:03 -05:00
parent 8b366ea97b
commit fd60b42f91
5 changed files with 18 additions and 9 deletions

View File

@ -53,6 +53,7 @@
"@angular/platform-browser": "19.2.0", "@angular/platform-browser": "19.2.0",
"ace-builds": "1.43.0", "ace-builds": "1.43.0",
"ace-diff": "3.0.3", "ace-diff": "3.0.3",
"ace-layout": "1.5.0",
"ace-linters": "1.7.0", "ace-linters": "1.7.0",
"bootstrap": "5.3.6", "bootstrap": "5.3.6",
"bootstrap-icons": "1.12.1", "bootstrap-icons": "1.12.1",

View File

@ -30,7 +30,7 @@ export class LspManagerService {
}); });
} }
public registerEditorToLSPClient(editor: any): void { public registerEditorToLSPClient(editor: any) {
let mode = this.getMode(editor.session); let mode = this.getMode(editor.session);
if ( this.languageProviders[mode] ) { if ( this.languageProviders[mode] ) {
@ -45,7 +45,7 @@ export class LspManagerService {
return window.fs.getLspConfigData(); return window.fs.getLspConfigData();
} }
private parseAndReturnLSPConfigData() { private parseAndReturnLSPConfigData(): {} {
let configData = JSON.parse( let configData = JSON.parse(
this.lspConfigDataStr.replaceAll("{workspace.folder}", this.workspaceFolder) this.lspConfigDataStr.replaceAll("{workspace.folder}", this.workspaceFolder)
); );
@ -62,7 +62,7 @@ export class LspManagerService {
return configData; return configData;
} }
private getInitializationOptions(mode: string, configData: {}) { private getInitializationOptions(mode: string, configData: {}): {} {
let _initializationOptions = {}; let _initializationOptions = {};
if ( Object.keys(configData).length !== 0 && configData[mode] ) { if ( Object.keys(configData).length !== 0 && configData[mode] ) {
@ -72,7 +72,7 @@ export class LspManagerService {
return _initializationOptions; return _initializationOptions;
} }
public createLanguageProviderWithClientServer(mode: string) { public createLanguageProviderWithClientServer(mode: string): LanguageProvider {
if ( this.languageProviders[mode] ) return; if ( this.languageProviders[mode] ) return;
let servers: LanguageClientConfig[] = []; let servers: LanguageClientConfig[] = [];
@ -97,10 +97,12 @@ export class LspManagerService {
} }
this.languageProviders[mode] = AceLanguageClient.for(servers); this.languageProviders[mode] = AceLanguageClient.for(servers);
// this.languageProviders[mode].requireFilePath = true;
this.languageProviders[mode].changeWorkspaceFolder(this.workspaceFolder);
return this.languageProviders[mode]; return this.languageProviders[mode];
} }
private getLanguageProviderWithWebWorker() { private getLanguageProviderWithWebWorker(): LanguageProvider {
let worker = new Worker(new URL('./webworker.js', import.meta.url)); let worker = new Worker(new URL('./webworker.js', import.meta.url));
return LanguageProvider.create(worker); return LanguageProvider.create(worker);
} }
@ -112,7 +114,7 @@ export class LspManagerService {
this.languageProviders[mode].setSessionFilePath(session, filePath); this.languageProviders[mode].setSessionFilePath(session, filePath);
} }
public getMode(session: any) { public getMode(session: any): string {
return session.getMode()["$id"].replace("ace/mode/", ""); return session.getMode()["$id"].replace("ace/mode/", "");
} }

View File

@ -62,7 +62,6 @@ export class FilesService {
): Promise<NewtonFile | undefined | null> { ): Promise<NewtonFile | undefined | null> {
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
const file = files[i]; const file = files[i];
// const path = window.fs.getPathForFile(file).replace("file://", "");
const path = window.fs.getPathForFile(file); const path = window.fs.getPathForFile(file);
if (!file || !path) continue; if (!file || !path) continue;
@ -90,7 +89,8 @@ export class FilesService {
if (loadFileContents) if (loadFileContents)
data = await window.fs.getFileContents(file.path); data = await window.fs.getFileContents(file.path);
file.session = new EditSession(data); file.session = new EditSession(data);
file.session["id"] = path;
file.session.setUndoManager( new UndoManager() ); file.session.setUndoManager( new UndoManager() );
file.session.setMode( getModeForPath( file.path ).mode ); file.session.setMode( getModeForPath( file.path ).mode );

View File

@ -2,6 +2,10 @@ import { Component } from "@angular/core";
// Import Ace and its modes/themes so that `ace` global is defined // Import Ace and its modes/themes so that `ace` global is defined
import * as ace from "ace-builds/src-min-noconflict/ace"; import * as ace from "ace-builds/src-min-noconflict/ace";
// Note: https://github.com/mkslanc/ace-linters/blob/c286d85c558530aa1b0597d02108bc782abd4736/packages/demo/file-api-websockets/client.ts#L27
// import { AceLayout, Box, TabManager, Button, dom, AceTreeWrapper, FileSystemWeb, Pane, AceEditor, Tab } from "ace-layout";
import "ace-builds/src-min-noconflict/ext-settings_menu"; import "ace-builds/src-min-noconflict/ext-settings_menu";
import "ace-builds/src-min-noconflict/ext-keybinding_menu"; import "ace-builds/src-min-noconflict/ext-keybinding_menu";
import "ace-builds/src-min-noconflict/ext-command_bar"; import "ace-builds/src-min-noconflict/ext-command_bar";

View File

@ -103,6 +103,7 @@ export class LspManagerComponent {
this.editor.session, this.editor.session,
this.activeFile.path this.activeFile.path
); );
} }
@ -124,7 +125,7 @@ export class LspManagerComponent {
// Note: hack for issue with setActiveEditor TODO // Note: hack for issue with setActiveEditor TODO
setTimeout(() => { setTimeout(() => {
this.innerEditor.setSession(this.editor.session); this.innerEditor.setSession(this.editor.getSession());
}, 10); }, 10);
} }
@ -145,6 +146,7 @@ export class LspManagerComponent {
this.editor.session, this.editor.session,
this.activeFile.path this.activeFile.path
); );
} }
private closeFile(message: ServiceMessage) { private closeFile(message: ServiceMessage) {