Skip to content

Commit

Permalink
add extra config option to server control exec & checking is PLI lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
spgennard committed Jun 11, 2024
1 parent dfcccca commit 44feec9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/iconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ export interface ICOBOLSettings {
enable_tabstops_anchors:boolean;

enable_microfocus_lsp_when_active: boolean;

enable_microfocus_lsp_lang_server_control : boolean;
}

export class COBOLSettings implements ICOBOLSettings {
Expand Down Expand Up @@ -280,6 +282,8 @@ export class COBOLSettings implements ICOBOLSettings {
enable_tabstops_anchors: boolean;

enable_microfocus_lsp_when_active:boolean;

enable_microfocus_lsp_lang_server_control: boolean;

constructor() {
this.enable_tabstop = true;
Expand Down Expand Up @@ -380,5 +384,6 @@ export class COBOLSettings implements ICOBOLSettings {
this.anchor_tabstops = [];
this.enable_tabstops_anchors = true;
this.enable_microfocus_lsp_when_active = true;
this.enable_microfocus_lsp_lang_server_control = true;
}
}
23 changes: 16 additions & 7 deletions src/vscommon_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ function newFile(title: string, template: string, doclang: string) {
});
}

function isMicroFocusLSPActive() : boolean {
function isMicroFocusLSPActive(): boolean {
const mfeditorConfig = vscode.workspace.getConfiguration("microFocusCOBOL");
return mfeditorConfig.get<boolean>("languageServerAutostart", true);
}

export async function toggleMicroFocusLSP(settings: ICOBOLSettings, onOrOff: boolean):Promise<void> {
function isMicroFocusPLI_LSPActive(): boolean {
const mfeditorConfig = vscode.workspace.getConfiguration("microFocusPLI");
return mfeditorConfig.get<boolean>("languageServer.autostart", true);
}

export async function toggleMicroFocusLSP(settings: ICOBOLSettings, onOrOff: boolean): Promise<void> {
// is it disabled?
if (settings.enable_microfocus_lsp_when_active === false) {
return;
Expand All @@ -83,8 +88,10 @@ export async function toggleMicroFocusLSP(settings: ICOBOLSettings, onOrOff: boo
await mfeditorConfig.update("languageServerAutostart", onOrOff);
}

const microFocusPLIConfig = vscode.workspace.getConfiguration("microFocusPLI");
microFocusPLIConfig.update("languageServer.autostart", onOrOff)
if (isMicroFocusPLI_LSPActive() != onOrOff) {
const microFocusPLIConfig = vscode.workspace.getConfiguration("microFocusPLI");
microFocusPLIConfig.update("languageServer.autostart", onOrOff);
}
}

export function activateCommonCommands(context: vscode.ExtensionContext, settings: ICOBOLSettings) {
Expand All @@ -105,7 +112,7 @@ export function activateCommonCommands(context: vscode.ExtensionContext, setting
}

vscode.languages.setTextDocumentLanguage(act.document, ExtensionDefaults.defaultCOBOLLanguage);

const mfExt = vscode.extensions.getExtension(ExtensionDefaults.microFocusCOBOLExtension);
if (mfExt) {
await toggleMicroFocusLSP(settings, false);
Expand All @@ -125,8 +132,10 @@ export function activateCommonCommands(context: vscode.ExtensionContext, setting

await toggleMicroFocusLSP(settings, true);

//vscode.window.showInformationMessage("Micro Focus Language Server may not be running.. please review");
//vscode.commands.executeCommand("mfcobol.languageServer.controls");
// invoke 'Micro Focus LSP Control'
if (settings.enable_microfocus_lsp_lang_server_control) {
vscode.commands.executeCommand("mfcobol.languageServer.controls");
}
}));

context.subscriptions.push(commands.registerCommand("cobolplugin.move2pd", function () {
Expand Down
2 changes: 2 additions & 0 deletions src/vsconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export class VSCOBOLConfiguration {

settings.enable_microfocus_lsp_when_active = getBoolean("enable_microfocus_lsp_when_active", settings.enable_microfocus_lsp_when_active);

settings.enable_microfocus_lsp_lang_server_control = getBoolean("enable_microfocus_lsp_lang_server_control", settings.enable_microfocus_lsp_lang_server_control);

return settings;
}

Expand Down

0 comments on commit 44feec9

Please sign in to comment.