WIP lsp-manager effort 3
This commit is contained in:
@@ -178,6 +178,11 @@ export class CodeViewBase {
|
||||
}
|
||||
|
||||
public closeFile() {
|
||||
let message = new ServiceMessage();
|
||||
message.action = "close-file";
|
||||
message.rawData = this.editor.getSession();
|
||||
|
||||
this.lspManagerService.sendMessage(message);
|
||||
this.tabsService.closeTab(this.activeFile.path);
|
||||
}
|
||||
|
||||
|
@@ -128,11 +128,11 @@ export class CodeViewComponent extends CodeViewBase {
|
||||
|
||||
this.editorsService.sendMessage(message);
|
||||
this.searchReplaceService.sendMessage(message);
|
||||
this.lspManagerService.sendMessage(message);
|
||||
|
||||
message = new ServiceMessage();
|
||||
message.action = "set-active-editor";
|
||||
message.rawData = this;
|
||||
this.lspManagerService.sendMessage(message);
|
||||
this.markdownPreviewService.sendMessage(message);
|
||||
|
||||
this.updateInfoBar();
|
||||
@@ -176,8 +176,8 @@ export class CodeViewComponent extends CodeViewBase {
|
||||
|
||||
this.editor.on("changeSession", (session) => {
|
||||
let message = new ServiceMessage();
|
||||
message.action = "set-active-editor";
|
||||
message.rawData = this.editor;
|
||||
message.action = "editor-update";
|
||||
message.rawData = this;
|
||||
|
||||
this.lspManagerService.sendMessage(message);
|
||||
|
||||
|
@@ -2,6 +2,10 @@
|
||||
|
||||
<div class="row mt-2 mb-3">
|
||||
|
||||
<div class="col col-auto">
|
||||
<button class="btn btn-sm btn-dark" (click)="createLanguageClient()">Create Language Client</button>
|
||||
</div>
|
||||
|
||||
<div class="col clear-right-padding">
|
||||
<div class="input-group-sm">
|
||||
<label class="form-control" [innerText]="lspManagerService.workspaceFolder || 'Project Path...'">
|
||||
@@ -36,7 +40,13 @@
|
||||
|
||||
<div class="row mt-2 md-2">
|
||||
<div class="col">
|
||||
Target Editor: <label [innerText]="editor?.id || 'Editor...'"></label>
|
||||
Target Editor: <label [innerText]="editor?.id || '...'"></label>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<button class="btn btn-sm btn-dark"
|
||||
(click)="registerEditorToLanguageClient()">
|
||||
Register Editor To LSP
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
Active Editor Session:
|
||||
|
@@ -34,6 +34,7 @@ export class LspManagerComponent {
|
||||
lspTextEditor: any;
|
||||
innerEditor: any;
|
||||
editor: any;
|
||||
activeFile: any;
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +44,16 @@ export class LspManagerComponent {
|
||||
|
||||
|
||||
private ngAfterViewInit(): void {
|
||||
this.mapEditorsAndLoadConfig();
|
||||
this.loadSubscribers();
|
||||
}
|
||||
|
||||
private ngOnDestroy() {
|
||||
this.unsubscribe.next();
|
||||
this.unsubscribe.complete();
|
||||
}
|
||||
|
||||
private mapEditorsAndLoadConfig() {
|
||||
this.lspTextEditor = this.lspEditorComponent.editor;
|
||||
this.innerEditor = this.sessionEditorComponent.editor;
|
||||
|
||||
@@ -50,13 +61,6 @@ export class LspManagerComponent {
|
||||
this.lspTextEditor.session.setMode("ace/mode/json");
|
||||
this.lspTextEditor.session.setValue(lspConfigData);
|
||||
});
|
||||
|
||||
this.loadSubscribers();
|
||||
}
|
||||
|
||||
private ngOnDestroy() {
|
||||
this.unsubscribe.next();
|
||||
this.unsubscribe.complete();
|
||||
}
|
||||
|
||||
private loadSubscribers() {
|
||||
@@ -67,6 +71,10 @@ export class LspManagerComponent {
|
||||
this.toggleLspManager(message);
|
||||
} else if (message.action === "set-active-editor") {
|
||||
this.setActiveEditor(message);
|
||||
} else if (message.action === "editor-update") {
|
||||
this.editorUpdate(message);
|
||||
} else if (message.action === "close-file") {
|
||||
this.closeFile(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -83,6 +91,19 @@ export class LspManagerComponent {
|
||||
});
|
||||
}
|
||||
|
||||
public createLanguageClient() {
|
||||
let mode = this.lspManagerService.getMode(this.editor.session);
|
||||
this.lspManagerService.createLanguageProviderWithClientServer(mode);
|
||||
}
|
||||
|
||||
public registerEditorToLanguageClient() {
|
||||
this.lspManagerService.registerEditorToLSPClient(this.editor);
|
||||
|
||||
this.lspManagerService.setSessionFilePath(
|
||||
this.editor.session,
|
||||
this.activeFile.path
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public globalLspManagerKeyHandler(event: any) {
|
||||
@@ -108,10 +129,26 @@ export class LspManagerComponent {
|
||||
}
|
||||
|
||||
private setActiveEditor(message: ServiceMessage) {
|
||||
this.editor = message.rawData;
|
||||
this.editor = message.rawData.editor;
|
||||
this.activeFile = message.rawData.activeFile;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
private editorUpdate(message: ServiceMessage) {
|
||||
this.editor.setSession(message.rawData.editor.getSession())
|
||||
this.activeFile = message.rawData.activeFile;
|
||||
|
||||
this.lspManagerService.setSessionFilePath(
|
||||
this.editor.session,
|
||||
this.activeFile.path
|
||||
);
|
||||
}
|
||||
|
||||
private closeFile(message: ServiceMessage) {
|
||||
this.lspManagerService.closeDocument(message.rawData);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user