Skip to content

Commit

Permalink
added ddp.DDPLS.path setting
Browse files Browse the repository at this point in the history
  • Loading branch information
bafto committed Dec 5, 2023
1 parent 372a407 commit 11a9193
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
"default": [],
"description": "arguments that are passed to $kddp starte"
},
"ddp.DDPLS.path": {
"type": "string",
"default": "",
"description": "if present this DDPLS binary is used instead of the one shipped with the extension or the global one"
},
"ddp.DDPLS.flags": {
"type": "array",
"default": [],
Expand Down
21 changes: 12 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ export function activate(ctx: vscode.ExtensionContext) {
out.appendLine("DDPPATH not found\nThis might cause errors in some commands");
}

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

let commandName = "DDPLS";
{
if (config.has("DDPLS.path")) {
let ddplsPath = config.get<string>("DDPLS.path");
if (ddplsPath !== "" && ddplsPath !== undefined) {
commandName = ddplsPath;
}
} else {
let ddplsPath = ctx.asAbsolutePath(path.join('bin', os.platform() === 'win32' ? 'DDPLS.exe' : 'DDPLS'));
if (fs.existsSync(ddplsPath)) {
commandName = ddplsPath;
}
}

let config = vscode.workspace.getConfiguration('ddp');
let lsArgs = config.get<string[]>("DDPLS.flags");
// DDPLS must be installed and in the PATH
let serverOptions: langsrv.ServerOptions = {
Expand Down Expand Up @@ -63,16 +69,13 @@ export function activate(ctx: vscode.ExtensionContext) {
return;
}

let config = vscode.workspace.getConfiguration('ddp');
let DDPPATH = "";
if (config.has("DDPPATH")) {
let ddppath = config.get("DDPPATH");
if (ddppath !== "") {
DDPPATH = config.get("DDPPATH");
let ddppath = config.get<string>("DDPPATH");
if (ddppath !== "" && ddppath !== undefined) {
DDPPATH = ddppath;
}
}
if (DDPPATH === undefined) {
DDPPATH = "";
}

let exe = path.join(DDPPATH, 'bin', os.platform() === 'win32' ? 'kddp.exe' : 'kddp').replace(new RegExp('\\' + path.sep, 'g'), '/');
let filePath = currentFile.replace(new RegExp('\\' + path.sep, 'g'), '/');
Expand Down

0 comments on commit 11a9193

Please sign in to comment.