WIP lsp-manager effort
This commit is contained in:
@@ -8,6 +8,7 @@ import { EditorsService } from '../../common/services/editor/editors.service';
|
||||
import { FilesService } from '../../common/services/files.service';
|
||||
import { SearchReplaceService } from '../../common/services/editor/search-replace/search-replace.service';
|
||||
import { MarkdownPreviewService } from '../../common/services/editor/markdown-preview/markdown-preview.service';
|
||||
import { LspManagerService } from '../../common/services/editor/lsp-manager/lsp-manager.service';
|
||||
|
||||
import { EditorSettings } from "../../common/configs/editor.config";
|
||||
import { NewtonFile } from '../../common/types/file.type';
|
||||
@@ -31,6 +32,7 @@ export class CodeViewBase {
|
||||
protected filesService: FilesService = inject(FilesService);
|
||||
protected searchReplaceService: SearchReplaceService = inject(SearchReplaceService);
|
||||
protected markdownPreviewService: MarkdownPreviewService = inject(MarkdownPreviewService);
|
||||
protected lspManagerService: LspManagerService = inject(LspManagerService);
|
||||
|
||||
@ViewChild('editor') editorElm!: ElementRef;
|
||||
@Input() editorSettings!: typeof EditorSettings;
|
||||
@@ -97,6 +99,12 @@ export class CodeViewBase {
|
||||
this.editor.showKeyboardShortcuts();
|
||||
}
|
||||
|
||||
public lspManagerPopup() {
|
||||
let message = new ServiceMessage();
|
||||
message.action = "toggle-lsp-manager";
|
||||
this.lspManagerService.sendMessage(message);
|
||||
}
|
||||
|
||||
public markdownPreviewPopup() {
|
||||
let message = new ServiceMessage();
|
||||
message.action = "toggle-markdown-preview";
|
||||
|
@@ -59,6 +59,12 @@ export class CodeViewComponent extends CodeViewBase {
|
||||
return;
|
||||
}
|
||||
|
||||
let message = new ServiceMessage();
|
||||
message.action = "register-editor";
|
||||
message.rawData = this;
|
||||
|
||||
this.lspManagerService.sendMessage(message);
|
||||
|
||||
this.loadAceKeyBindings();
|
||||
this.loadAceEventBindings();
|
||||
}
|
||||
@@ -116,6 +122,7 @@ export class CodeViewComponent extends CodeViewBase {
|
||||
|
||||
this.editorsService.sendMessage(message);
|
||||
this.searchReplaceService.sendMessage(message);
|
||||
this.editorsService.sendMessage(message);
|
||||
|
||||
message = new ServiceMessage();
|
||||
message.action = "set-active-editor";
|
||||
|
3
src/app/editor/lsp-manager/lsp-manager.component.css
Normal file
3
src/app/editor/lsp-manager/lsp-manager.component.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.lsp-config-text {
|
||||
min-height: 25em;
|
||||
}
|
27
src/app/editor/lsp-manager/lsp-manager.component.html
Normal file
27
src/app/editor/lsp-manager/lsp-manager.component.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row mt-2 mb-3">
|
||||
|
||||
<div class="col">
|
||||
<div class="input-group-sm">
|
||||
<input class="form-control" placeholder="Project Path..." />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col col-auto">
|
||||
<div class="input-group-sm">
|
||||
<button class="btn btn-sm btn-dark">Choose Directory</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
<textarea #lspConfigText class="form-control form-control-sm lsp-config-text" placeholder="LSP Config..."> </textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
87
src/app/editor/lsp-manager/lsp-manager.component.ts
Normal file
87
src/app/editor/lsp-manager/lsp-manager.component.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { Component, ElementRef, HostBinding, ViewChild, inject } from '@angular/core';
|
||||
import { Subject, takeUntil } from 'rxjs';
|
||||
|
||||
import { LspManagerService } from '../../common/services/editor/lsp-manager/lsp-manager.service';
|
||||
|
||||
import { ServiceMessage } from '../../common/types/service-message.type';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'lsp-manager',
|
||||
standalone: true,
|
||||
imports: [
|
||||
],
|
||||
templateUrl: './lsp-manager.component.html',
|
||||
styleUrl: './lsp-manager.component.css',
|
||||
host: {
|
||||
'class': 'lsp-manager',
|
||||
"(keyup)": "globalLspManagerKeyHandler($event)"
|
||||
}
|
||||
})
|
||||
export class LspManagerComponent {
|
||||
private unsubscribe: Subject<void> = new Subject();
|
||||
|
||||
private lspManagerService: LspManagerService = inject(LspManagerService);
|
||||
|
||||
@HostBinding("class.hidden") isHidden: boolean = true;
|
||||
@ViewChild('lspConfigText') lspConfigText!: ElementRef;
|
||||
private editors: any = {};
|
||||
private editor: any;
|
||||
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
|
||||
private ngAfterViewInit(): void {
|
||||
this.lspConfigText.nativeElement.value = this.lspManagerService.lspConfigData;
|
||||
|
||||
this.loadSubscribers();
|
||||
}
|
||||
|
||||
private ngOnDestroy() {
|
||||
this.unsubscribe.next();
|
||||
this.unsubscribe.complete();
|
||||
}
|
||||
|
||||
private loadSubscribers() {
|
||||
this.lspManagerService.getMessage$().pipe(
|
||||
takeUntil(this.unsubscribe)
|
||||
).subscribe((message: ServiceMessage) => {
|
||||
if (message.action === "toggle-lsp-manager") {
|
||||
this.toggleLspManager(message);
|
||||
} else if (message.action === "set-active-editor") {
|
||||
this.setActiveEditor(message);
|
||||
} else if (message.action === "register-editor") {
|
||||
this.registerEditor(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public hideLspManager() {
|
||||
this.isHidden = true;
|
||||
this.editor.focus();
|
||||
}
|
||||
|
||||
public globalLspManagerKeyHandler(event: any) {
|
||||
if (event.ctrlKey && event.shiftKey && event.key === "l") {
|
||||
this.hideLspManager();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private toggleLspManager(message: ServiceMessage) {
|
||||
this.isHidden = !this.isHidden;
|
||||
}
|
||||
|
||||
private setActiveEditor(message: ServiceMessage) {
|
||||
this.editor = this.editors[message.editorUUID];
|
||||
}
|
||||
|
||||
private registerEditor(message: ServiceMessage) {
|
||||
let _editor = message.rawData;
|
||||
this.editors[_editor.uuid] = _editor.editor;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user