diff --git a/package.json b/package.json index def2a9fa39..678917d9db 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,28 @@ "type": "boolean", "default": false, "description": "Suppress the warning that the .NET CLI is not on the path." + }, + "omnisharp.path": { + "type": [ + "string", + "null" + ], + "default": null, + "description": "Specifies the full path to the OmniSharp server." + }, + "omnisharp.useMono": { + "type": "boolean", + "default": false, + "description": "Launch OmniSharp with Mono." + }, + "omnisharp.loggingLevel": { + "type": "string", + "default": "default", + "enum": [ + "default", + "verbose" + ], + "description": "Specifies the level of logging output from the OmniSharp server." } } }, diff --git a/src/omnisharp/omnisharp.ts b/src/omnisharp/omnisharp.ts index f07246ba7c..d5794d86ea 100644 --- a/src/omnisharp/omnisharp.ts +++ b/src/omnisharp/omnisharp.ts @@ -14,8 +14,9 @@ import * as fs from 'fs-extra-promise'; import * as path from 'path'; export interface Options { - path?: string; - usesMono?: boolean; + path?: string; + useMono?: boolean; + loggingLevel?: string; } export enum Flavor { diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index 680e92abb9..5ec61bc629 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -104,12 +104,26 @@ export abstract class OmnisharpServer { } private _readOptions(): omnisharp.Options { - const config = vscode.workspace.getConfiguration('csharp'); + // Extra effort is taken below to ensure that legacy versions of options + // are supported below. In particular, these are: + // + // - "csharp.omnisharp" -> "omnisharp.path" + // - "csharp.omnisharpUsesMono" -> "omnisharp.useMono" - return { - path: config.get('omnisharp'), - usesMono: config.get('omnisharpUsesMono') - }; + const omnisharpConfig = vscode.workspace.getConfiguration('omnisharp'); + const csharpConfig = vscode.workspace.getConfiguration('csharp'); + + const path = omnisharpConfig.has('path') + ? omnisharpConfig.get('path') + : csharpConfig.get('omnisharp'); + + const useMono = omnisharpConfig.has('useMono') + ? omnisharpConfig.get('useMono') + : csharpConfig.get('omnisharpUsesMono'); + + const loggingLevel = omnisharpConfig.get('loggingLevel'); + + return { path, useMono, loggingLevel }; } private _recordRequestDelay(requestName: string, elapsedTime: number) { @@ -237,7 +251,7 @@ export abstract class OmnisharpServer { const options = this._readOptions(); let flavor: omnisharp.Flavor; - if (options.path !== undefined && options.usesMono === true) { + if (options.path !== undefined && options.useMono === true) { flavor = omnisharp.Flavor.Mono; } else { @@ -250,11 +264,17 @@ export abstract class OmnisharpServer { const solutionPath = launchTarget.target; const cwd = dirname(solutionPath); - const args = [ + let args = [ '-s', solutionPath, '--hostPID', process.pid.toString(), 'DotNet:enablePackageRestore=false' - ].concat(this._extraArgs); + ]; + + if (options.loggingLevel === 'verbose') { + args.push('-v'); + } + + args = args.concat(this._extraArgs); this._fireEvent(Events.StdOut, `[INFO] Starting OmniSharp at '${solutionPath}'...\n`); this._fireEvent(Events.BeforeServerStart, solutionPath); @@ -391,7 +411,7 @@ export abstract class OmnisharpServer { return omnisharp.findServerPath(options.path).then(serverPath => { return resolve(serverPath); }).catch(err => { - vscode.window.showWarningMessage(`Invalid "csharp.omnisharp" user setting specified ('${options.path}).`); + vscode.window.showWarningMessage(`Invalid value specified for "omnisharp.path" ('${options.path}).`); return reject(err); }); } @@ -409,9 +429,9 @@ export abstract class OmnisharpServer { this._channel.appendLine(" 1. If it's not already installed, download and install Mono (https://www.mono-project.com)"); this._channel.appendLine(" 2. Download and untar the latest OmniSharp Mono release from https://github.com/OmniSharp/omnisharp-roslyn/releases/"); this._channel.appendLine(" 3. In Visual Studio Code, select Preferences->User Settings to open settings.json."); - this._channel.appendLine(" 4. In settings.json, add a new setting: \"csharp.omnisharp\": \"/path/to/omnisharp/OmniSharp.exe\""); - this._channel.appendLine(" 4. In settings.json, add a new setting: \"csharp.omnisharpUsesMono\": true"); - this._channel.appendLine(" 5. Restart Visual Studio Code."); + this._channel.appendLine(" 4. In settings.json, add a new setting: \"omnisharp.path\": \"/path/to/omnisharp/OmniSharp.exe\""); + this._channel.appendLine(" 5. In settings.json, add a new setting: \"omnisharp.useMono\": true"); + this._channel.appendLine(" 6. Restart Visual Studio Code."); this._channel.show(); throw err;