Skip to content

Commit

Permalink
Debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
georgewfraser committed Feb 16, 2019
1 parent 7e00a6b commit 38757b9
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,33 @@
'use strict';

import * as path from 'path';
import * as fs from "fs";
import * as cp from 'child_process';
import { window, workspace, ExtensionContext, Progress, Range, commands, tasks, Task, TaskExecution, ShellExecution, Uri, TaskDefinition, debug } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, NotificationType } from 'vscode-languageclient';

// Run using `dotnet` instead of self-contained executable
const debugMode = false;

export function activate(context: ExtensionContext) {

// The server is packaged as a standalone command
let serverMain = context.asAbsolutePath(binName());

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run : { command: serverMain, args: [], transport: TransportKind.stdio },
debug : { command: serverMain, args: [], transport: TransportKind.stdio }
let serverOptions: ServerOptions = {
command: serverMain,
args: [],
transport: TransportKind.stdio
}
if (debugMode) {
serverOptions = {
command: findInPath('dotnet'),
args: ['run', '--project', 'src/FSharpLanguageServer'],
transport: TransportKind.stdio,
options: { cwd: context.extensionPath }
}
}

// Options to control the language client
Expand Down Expand Up @@ -224,3 +237,14 @@ function getPathParts(platform: string): string[] {

throw `unsupported platform: ${platform}`;
}

function findInPath(binname: string) {
let pathparts = process.env['PATH'].split(path.delimiter);
for (let i = 0; i < pathparts.length; i++) {
let binpath = path.join(pathparts[i], binname);
if (fs.existsSync(binpath)) {
return binpath;
}
}
return null;
}

0 comments on commit 38757b9

Please sign in to comment.