Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Expose trace verbosity #41

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ 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';

export enum RustLog {
Unspecified = null,
Error = <any>"error",
Warn = <any>"warn",
Info = <any>"info",
Debug = <any>"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 = ['|', '/', '-', '\\'];
Expand Down Expand Up @@ -40,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<child_process.ChildProcess>((resolve, reject) => {
Expand Down Expand Up @@ -76,6 +93,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) {
Expand Down