Various LSP or LSP tangental changes
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ReplaySubject, Observable } from 'rxjs';
|
||||
|
||||
import { CompletionProvider } from "ace-builds/src-min-noconflict/ace";
|
||||
import { CommandBarTooltip } from "ace-builds/src-min-noconflict/ext-command_bar";
|
||||
import { InlineAutocomplete } from "ace-builds/src-min-noconflict/ext-inline_autocomplete";
|
||||
|
||||
import { AceLanguageClient, LanguageClientConfig } from 'ace-linters/build/ace-language-client';
|
||||
import { LanguageProvider } from "ace-linters";
|
||||
|
||||
|
||||
|
||||
import { ServiceMessage } from '../../../types/service-message.type';
|
||||
|
||||
|
||||
@@ -61,13 +67,13 @@ export class LspManagerService {
|
||||
}
|
||||
|
||||
private getInitializationOptions(mode: string, configData: {}): {} {
|
||||
let _initializationOptions = {};
|
||||
let initializationOptions = {};
|
||||
|
||||
if ( Object.keys(configData).length !== 0 && configData[mode] ) {
|
||||
_initializationOptions = configData[mode]["initialization-options"];
|
||||
initializationOptions = configData[mode]["initialization-options"];
|
||||
}
|
||||
|
||||
return _initializationOptions;
|
||||
return initializationOptions;
|
||||
}
|
||||
|
||||
public createLanguageProviderWithClientServer(mode: string): LanguageProvider {
|
||||
@@ -75,15 +81,15 @@ export class LspManagerService {
|
||||
let servers: LanguageClientConfig[] = [];
|
||||
|
||||
try {
|
||||
let configData = this.parseAndReturnLSPConfigData();
|
||||
let _initializationOptions = this.getInitializationOptions(mode, configData);
|
||||
let lspConfigData = this.parseAndReturnLSPConfigData();
|
||||
let initializationOptions = this.getInitializationOptions(mode, lspConfigData);
|
||||
servers = [
|
||||
{
|
||||
module: () => import("ace-linters/build/language-client"),
|
||||
modes: mode,
|
||||
type: "socket",
|
||||
socket: new WebSocket( configData[mode]["socket"] ),
|
||||
initializationOptions: _initializationOptions
|
||||
socket: new WebSocket( lspConfigData[mode]["socket"] ),
|
||||
initializationOptions: initializationOptions
|
||||
}
|
||||
];
|
||||
} catch(error) {
|
||||
@@ -97,14 +103,51 @@ export class LspManagerService {
|
||||
this.languageProviders[mode] = AceLanguageClient.for(
|
||||
servers,
|
||||
{
|
||||
workspacePath: this.workspaceFolder,
|
||||
functionality: {
|
||||
hover: true,
|
||||
completion: {
|
||||
overwriteCompleters: true,
|
||||
lspCompleterOptions: {
|
||||
triggerCharacters: {
|
||||
add: [
|
||||
" ",
|
||||
".",
|
||||
"@"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
// inlineCompletion: {
|
||||
// overwriteCompleters: true
|
||||
// },
|
||||
completionResolve: true,
|
||||
format: true,
|
||||
documentHighlights: true,
|
||||
signatureHelp: true,
|
||||
semanticTokens: true,
|
||||
codeActions: true
|
||||
},
|
||||
// aceComponents: {
|
||||
// InlineAutocomplete,
|
||||
// CommandBarTooltip,
|
||||
// CompletionProvider
|
||||
// },
|
||||
manualSessionControl: true
|
||||
}
|
||||
);
|
||||
|
||||
this.languageProviders[mode].changeWorkspaceFolder(this.workspaceFolder);
|
||||
return this.languageProviders[mode];
|
||||
}
|
||||
|
||||
public closeLanguageProviderWithClientServer(mode: string): LanguageProvider {
|
||||
if ( !this.languageProviders[mode] ) return;
|
||||
|
||||
let connection = this.languageProviders[mode];
|
||||
delete this.languageProviders[mode];
|
||||
connection.closeConnection();
|
||||
}
|
||||
|
||||
private getLanguageProviderWithWebWorker(): LanguageProvider {
|
||||
let worker = new Worker(new URL('./webworker.js', import.meta.url));
|
||||
return LanguageProvider.create(worker);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<div class="row mt-2 md-2">
|
||||
<div class="col col-sm" [hidden]="!lspManagerService.workspaceFolder">
|
||||
<button class="btn btn-sm btn-dark" (click)="createLanguageClient()">Create Language Client</button>
|
||||
<button class="btn btn-sm btn-dark" (click)="closeLanguageClient()">Close Language Client</button>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
|
||||
@@ -99,6 +99,11 @@ export class LspManagerComponent {
|
||||
this.lspManagerService.createLanguageProviderWithClientServer(mode);
|
||||
}
|
||||
|
||||
public closeLanguageClient() {
|
||||
let mode = this.lspManagerService.getMode(this.editor.session);
|
||||
this.lspManagerService.closeLanguageProviderWithClientServer(mode);
|
||||
}
|
||||
|
||||
public registerEditorToLanguageClient() {
|
||||
this.lspManagerService.registerEditorToLSPClient(this.editor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user