Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Added revealOutputChannelOn. #113

Merged
merged 3 commits into from
Feb 26, 2017
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions doc/rls_mode/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ The type of the parameter is an object with the following fields:
* `"executable"` - a string. The path to an executable to execute
* `"args"` - an array of strings. Arguments to pass to the executable
* `"env"` - an environment to append to the current environment to execute the executable
* `"revealOutputChannelOn"` - a string. Specifies the condition when the output channel should be revealed

By default, it is `null`.

### The revealOutputChannelOn configuration parameter

This determines when the Output channel is revealed.

The possible values are:

* `"info"` - revealed on each info line
* `"warn"` - revealed on each warn line
* `"error"` - revealed on each error line (default)
* `"never"` - the output channel never reveals automatically

Copy link
Contributor

@redactedscribe redactedscribe Feb 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line about when "never" can be used was removed as I think its use case is obvious.

## Setting up

First of all, you have to download the [RLS](https://github.com/rust-lang-nursery/rls) sources:
Expand Down
22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,29 @@
"items": {
"type": "string"
},
"type": "array"
"type": [
"array",
"null"
]
},
"env": {
"default": null,
"description": "An environment to run the executable in"
"description": "An environment to run the executable in",
"type": [
"object",
"null"
]
},
"revealOutputChannelOn": {
"default": "error",
"description": "Specifies when the output channel should be revealed",
"enum": [
"info",
"warn",
"error",
"never"
],
"type": "string"
}
}
}
Expand Down
49 changes: 45 additions & 4 deletions src/components/configuration/configuration_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { join } from 'path';

import { WorkspaceConfiguration, workspace } from 'vscode';

import { RevealOutputChannelOn } from 'vscode-languageclient';

import expandTilde = require('expand-tilde');

export interface RlsConfiguration {
Expand All @@ -14,6 +16,8 @@ export interface RlsConfiguration {
args?: string[];

env?: any;

revealOutputChannelOn: RevealOutputChannelOn;
}

export enum ActionOnStartingCommandIfThereIsRunningCommand {
Expand All @@ -35,17 +39,54 @@ export class ConfigurationManager {
return new ConfigurationManager(rustcSysRoot, rustSourcePath);
}

public getRlsConfiguration(): RlsConfiguration | null {
public getRlsConfiguration(): RlsConfiguration | undefined {
const configuration = ConfigurationManager.getConfiguration();

const rlsConfiguration: RlsConfiguration | null = configuration['rls'];
const rlsConfiguration: any | null = configuration['rls'];

if (rlsConfiguration === null) {
return undefined;
}

const executable: string = rlsConfiguration.executable;
const args: string[] | null = rlsConfiguration.args;
const env: any | null = rlsConfiguration.env;
const revealOutputChannelOn: string = rlsConfiguration.revealOutputChannelOn;

let revealOutputChannelOnEnum: RevealOutputChannelOn;

switch (revealOutputChannelOn) {
case 'info':
revealOutputChannelOnEnum = RevealOutputChannelOn.Info;
break;

case 'warn':
revealOutputChannelOnEnum = RevealOutputChannelOn.Warn;
break;

case 'error':
revealOutputChannelOnEnum = RevealOutputChannelOn.Error;
break;

case 'never':
revealOutputChannelOnEnum = RevealOutputChannelOn.Never;
break;

default:
revealOutputChannelOnEnum = RevealOutputChannelOn.Error;
}

return rlsConfiguration;
return {
executable,
args: args !== null ? args : undefined,
env: env !== null ? env : undefined,
revealOutputChannelOn: revealOutputChannelOnEnum
};
}

public shouldExecuteCargoCommandInTerminal(): boolean {
// When RLS is used any cargo command is executed in an integrated terminal.
if (this.getRlsConfiguration()) {
if (this.getRlsConfiguration() !== undefined) {
return true;
}

Expand Down
7 changes: 4 additions & 3 deletions src/components/language_client/creator.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { LanguageClient, LanguageClientOptions as ClientOptions, ServerOptions } from 'vscode-languageclient';
import { LanguageClient, LanguageClientOptions as ClientOptions, RevealOutputChannelOn, ServerOptions } from 'vscode-languageclient';

export class Creator {
private clientOptions: ClientOptions;

private serverOptions: ServerOptions;

public constructor(executable: string, args?: string[], env?: any) {
public constructor(executable: string, args: string[] | undefined, env: any | undefined, revealOutputChannelOn: RevealOutputChannelOn) {
this.clientOptions = {
documentSelector: ['rust'],
revealOutputChannelOn,
synchronize: {
configurationSection: 'languageServerExample'
}
};

this.serverOptions = {
command: executable,
args: args,
args,
options: {
env: Object.assign({}, process.env, env ? env : {})
}
Expand Down
9 changes: 5 additions & 4 deletions src/components/language_client/manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExtensionContext } from 'vscode';

import { LanguageClient, State } from 'vscode-languageclient';
import { LanguageClient, RevealOutputChannelOn, State } from 'vscode-languageclient';

import ChildLogger from '../logging/child_logger';

Expand All @@ -23,10 +23,11 @@ export class Manager {
context: ExtensionContext,
logger: ChildLogger,
executable: string,
args?: string[],
env?: any
args: string[] | undefined,
env: any | undefined,
revealOutputChannelOn: RevealOutputChannelOn
) {
this.languageClientCreator = new LanguageClientCreator(executable, args, env);
this.languageClientCreator = new LanguageClientCreator(executable, args, env, revealOutputChannelOn);

this.context = context;

Expand Down
9 changes: 5 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {

const currentWorkingDirectoryManager = new CurrentWorkingDirectoryManager();

const rlsConfiguration: RlsConfiguration | null = configurationManager.getRlsConfiguration();
const rlsConfiguration: RlsConfiguration | undefined = configurationManager.getRlsConfiguration();

const cargoManager = new CargoManager(
ctx,
Expand All @@ -32,8 +32,8 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
logger.createChildLogger('Cargo Manager: ')
);

if (rlsConfiguration) {
let { executable, args, env } = rlsConfiguration;
if (rlsConfiguration !== undefined) {
let { executable, args, env, revealOutputChannelOn } = rlsConfiguration;

if (!env) {
env = {};
Expand All @@ -48,7 +48,8 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
logger.createChildLogger('Language Client Manager: '),
executable,
args,
env
env,
revealOutputChannelOn
);

languageClientManager.start();
Expand Down