From 44781f5c7fbe047ac7727fe5b3dd3d9fff50c723 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 1 Apr 2017 17:40:41 +0200 Subject: [PATCH 1/2] expose LanguageClient trace verbosity API --- src/extension.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index a5ddea90..9c848dbf 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,8 +6,10 @@ import * as child_process from 'child_process'; import { workspace, Disposable, ExtensionContext, languages, window } from 'vscode'; import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient'; +import { Trace } from 'vscode-jsonrpc'; let DEV_MODE = false; +let CLIENT_TRACE = Trace.Messages; let spinnerTimer = null; let spinner = ['|', '/', '-', '\\']; @@ -76,6 +78,9 @@ export function activate(context: ExtensionContext) { // Create the language client and start the client. let lc = new LanguageClient('Rust Language Server', serverOptions, clientOptions); + // Set appropriate client trace verbosity level in dev mode. + // Trace.Verbose provides full protocol messages in the client output channel. + lc.trace = DEV_MODE ? CLIENT_TRACE : Trace.Off; let runningDiagnostics = new Counter(); lc.onNotification({method: "rustDocument/diagnosticsBegin"}, function(f) { From 1f001ea517f8b89f6716aa5094f7e086a63149ab Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 1 Apr 2017 19:07:54 +0200 Subject: [PATCH 2/2] allow for setting RUST_LOG when starting the server --- src/extension.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 9c848dbf..f5a654ec 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,8 +8,18 @@ import { workspace, Disposable, ExtensionContext, languages, window } from 'vsco import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient'; import { Trace } from 'vscode-jsonrpc'; +export enum RustLog { + Unspecified = null, + Error = "error", + Warn = "warn", + Info = "info", + Debug = "debug" +} + let DEV_MODE = false; +// Settings below are applied for DEV_MODE = true let CLIENT_TRACE = Trace.Messages; +let RUST_LOG = RustLog.Unspecified; let spinnerTimer = null; let spinner = ['|', '/', '-', '\\']; @@ -42,10 +52,15 @@ export function activate(context: ExtensionContext) { window.setStatusBarMessage("RLS analysis: starting up"); if (DEV_MODE) { + let env = process.env; + if (RUST_LOG != RustLog.Unspecified) { + env.RUST_LOG = RUST_LOG; + } + if (rls_root) { - serverOptions = {command: "cargo", args: ["run", "--release"], options: { cwd: rls_root } }; + serverOptions = {command: "cargo", args: ["run", "--release"], options: { env: env, cwd: rls_root } }; } else { - serverOptions = {command: "rls"}; + serverOptions = {command: "rls", options: { env: env } }; } } else { serverOptions = () => new Promise((resolve, reject) => {