WIP lsp-manager effort 2

This commit is contained in:
2025-07-06 21:40:24 -05:00
parent 9e01628ffb
commit f463970b6b
11 changed files with 124 additions and 26 deletions

View File

@@ -59,8 +59,8 @@ export class CodeViewComponent extends CodeViewBase {
this.editor = ace.edit( this.editorElm.nativeElement );
this.editor.setOptions( this.editorSettings.CONFIG );
this.editorsService.set(this.uuid, this);
if (this.isDefault) {
this.editorsService.set(this.uuid, this);
this.editorsService.setActiveEditor(this.uuid);
this.addActiveStyling();
this.editor.focus();
@@ -128,7 +128,7 @@ export class CodeViewComponent extends CodeViewBase {
this.editorsService.sendMessage(message);
this.searchReplaceService.sendMessage(message);
this.editorsService.sendMessage(message);
this.lspManagerService.sendMessage(message);
message = new ServiceMessage();
message.action = "set-active-editor";
@@ -175,6 +175,12 @@ export class CodeViewComponent extends CodeViewBase {
});
this.editor.on("changeSession", (session) => {
let message = new ServiceMessage();
message.action = "set-active-editor";
message.rawData = this.editor;
this.lspManagerService.sendMessage(message);
this.updateInfoBar();
});
}

View File

@@ -1,4 +1,11 @@
.lsp-config-text {
display: grid;
min-height: 25em;
}
}
.clear-left-padding {
padding-left: 0px;
}
.clear-right-padding {
padding-right: 0px;
}

View File

@@ -2,24 +2,51 @@
<div class="row mt-2 mb-3">
<div class="col">
<div class="col clear-right-padding">
<div class="input-group-sm">
<input class="form-control" placeholder="Project Path..." />
<label class="form-control" [innerText]="lspManagerService.workspaceFolder || 'Project Path...'">
</label>
</div>
</div>
<div class="col col-auto clear-left-padding">
<button class="btn btn-sm btn-dark" (click)="clearWorkspaceFolder()">x</button>
</div>
<div class="col col-auto">
<div class="input-group-sm">
<button class="btn btn-sm btn-dark">Choose Directory</button>
<button class="btn btn-sm btn-dark" (click)="setWorkspaceFolder()">Workspace Folder</button>
<button class="btn btn-sm btn-danger ms-5" (click)="hideLspManager()">X</button>
</div>
</div>
</div>
<div class="row mt-2 md-2">
<div class="col">
LSP Configs:
</div>
</div>
<div class="row">
<div class="col">
<code-view #lspEditorComponent [mode]="'standalone'" class="lsp-config-text"></code-view>
</div>
</div>
<div class="row mt-2 md-2">
<div class="col">
Target Editor: <label [innerText]="editor?.id || 'Editor...'"></label>
</div>
<div class="col">
Active Editor Session:
</div>
</div>
<div class="row">
<div class="col">
<code-view #editorComponent [mode]="'standalone'" class="lsp-config-text"></code-view>
<code-view #sessionEditorComponent [mode]="'read-only'" class="lsp-config-text"></code-view>
</div>
</div>

View File

@@ -1,4 +1,4 @@
import { Component, ElementRef, HostBinding, ViewChild, inject } from '@angular/core';
import { Component, ChangeDetectorRef, ElementRef, HostBinding, ViewChild, inject } from '@angular/core';
import { Subject, takeUntil } from 'rxjs';
import { LspManagerService } from '../../common/services/editor/lsp-manager/lsp-manager.service';
@@ -23,14 +23,19 @@ import { ServiceMessage } from '../../common/types/service-message.type';
}
})
export class LspManagerComponent {
private unsubscribe: Subject<void> = new Subject();
private unsubscribe: Subject<void> = new Subject();
private changeDetectorRef: ChangeDetectorRef = inject(ChangeDetectorRef);
private lspManagerService: LspManagerService = inject(LspManagerService);
lspManagerService: LspManagerService = inject(LspManagerService);
@HostBinding("class.hidden") isHidden: boolean = true;
@ViewChild('editorComponent') editorComponent!: CodeViewComponent;
lspTextEditor!: any;
private editor: any;
@ViewChild('lspEditorComponent') lspEditorComponent!: CodeViewComponent;
@ViewChild('sessionEditorComponent') sessionEditorComponent!: CodeViewComponent;
lspTextEditor: any;
innerEditor: any;
editor: any;
constructor() {
@@ -38,7 +43,8 @@ export class LspManagerComponent {
private ngAfterViewInit(): void {
this.lspTextEditor = this.editorComponent.editor;
this.lspTextEditor = this.lspEditorComponent.editor;
this.innerEditor = this.sessionEditorComponent.editor;
this.lspManagerService.loadLspConfigData().then((lspConfigData) => {
this.lspTextEditor.session.setMode("ace/mode/json");
@@ -65,24 +71,47 @@ export class LspManagerComponent {
});
}
public hideLspManager() {
this.isHidden = true;
this.editor.focus();
public clearWorkspaceFolder() {
this.lspManagerService.workspaceFolder = "";
}
public setWorkspaceFolder() {
window.fs.chooseFolder().then((folder: string) => {
if (!folder) return;
this.lspManagerService.workspaceFolder = folder;
});
}
public globalLspManagerKeyHandler(event: any) {
if (event.ctrlKey && event.shiftKey && event.key === "l") {
this.hideLspManager();
}
}
public hideLspManager() {
this.isHidden = true;
this.editor.focus();
}
private toggleLspManager(message: ServiceMessage) {
this.isHidden = !this.isHidden;
if (this.isHidden) return;
// Note: hack for issue with setActiveEditor TODO
setTimeout(() => {
this.innerEditor.setSession(this.editor.session);
}, 10);
}
private setActiveEditor(message: ServiceMessage) {
this.editor = message.rawData;
// TODO: figure out why this doesn't update the session consistently...
// It seems maybe bound to visible state as change detector ref didn't help either.
// this.innerEditor.setSession(this.editor.session);
}
}

View File

@@ -61,7 +61,7 @@ export class MarkdownPreviewComponent {
setTimeout(() => {
this.updatePreview();
}, 200);
}, 10);
}
private setActiveEditor(message: ServiceMessage) {