Skip to content

Commit

Permalink
added setting DDPLS.useSystemwideInstall
Browse files Browse the repository at this point in the history
  • Loading branch information
bafto committed Apr 27, 2024
1 parent 75668cd commit f9684aa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
"default": "",
"description": "if present this DDPLS binary is used instead of the one shipped with the extension or the global one"
},
"ddp.DDPLS.useSystemwideInstall": {
"type": "boolean",
"default": false,
"description": "if true the system-wide installed DDPLS is used instead of the one shipped with the extension"
},
"ddp.DDPLS.flags": {
"type": "array",
"default": [],
Expand All @@ -106,6 +111,7 @@
}
},
"dependencies": {
"lookpath": "^1.2.2",
"vscode-languageclient": "^7.0.0"
},
"scripts": {
Expand All @@ -128,4 +134,4 @@
"mocha": "^10.0.0",
"typescript": "^4.7.2"
}
}
}
33 changes: 22 additions & 11 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import * as langsrv from 'vscode-languageclient/node';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import { lookpath } from 'lookpath';

let DDPPATH = process.env.DDPPATH;

export function activate(ctx: vscode.ExtensionContext) {
export async function activate(ctx: vscode.ExtensionContext) {
console.log('ddp extension activated');

let out = vscode.window.createOutputChannel("vscode-ddp", "ddp");
Expand All @@ -20,29 +21,39 @@ export function activate(ctx: vscode.ExtensionContext) {

let config = vscode.workspace.getConfiguration('ddp');

let commandName = "DDPLS";
let ddplsCommand = os.platform() === 'win32' ? 'DDPLS.exe' : 'DDPLS';
{
let ddplsPath = ctx.asAbsolutePath(path.join('bin', os.platform() === 'win32' ? 'DDPLS.exe' : 'DDPLS'));
out.appendLine("bundled ddplsPath: " + ddplsPath);
let ddplsPath = ctx.asAbsolutePath(path.join('bin', ddplsCommand));
if (fs.existsSync(ddplsPath)) {
out.appendLine("using bundled DDPLS");
out.appendLine(ddplsPath);
commandName = ddplsPath;
out.appendLine("found bundled DDPLS: " + ddplsPath);
ddplsCommand = ddplsPath;
}
}
{
let useSystemLs = config.get<boolean>("DDPLS.useSystemwideInstall");
if (useSystemLs === true) {
let ddplsPath = await lookpath('DDPLS');
if (ddplsPath !== undefined) {
out.appendLine("using system-wide DDPLS: " + ddplsPath);
ddplsCommand = ddplsPath;
} else {
out.appendLine("no system-wide DDPLS found, falling back to bundled DDPLS");
}
}
}
{
let ddplsPath = config.get<string>("DDPLS.path");
if (ddplsPath !== "" && ddplsPath !== undefined) {
out.appendLine("using custom DDPLS path");
commandName = ddplsPath;
out.appendLine("using custom DDPLS path: " + ddplsPath);
ddplsCommand = ddplsPath;
}
}

let lsArgs = config.get<string[]>("DDPLS.flags");
// DDPLS must be installed and in the PATH
let serverOptions: langsrv.ServerOptions = {
run: { command: commandName, args: lsArgs },
debug: { command: commandName, args: lsArgs }
run: { command: ddplsCommand, args: lsArgs },
debug: { command: ddplsCommand, args: lsArgs }
};

let clientOptions: langsrv.LanguageClientOptions = {
Expand Down

0 comments on commit f9684aa

Please sign in to comment.