Skip to content

Commit

Permalink
Add configuration for 'elixir' command (#115)
Browse files Browse the repository at this point in the history
This adds a new configuration allowing users to change the command used
to launch elixir_sense and alchemist-server.

`elixir` remains the default. Users without a need won't notice a
change.

Closes #109
  • Loading branch information
timmhirsens committed Feb 28, 2018
1 parent cbd3ef3 commit 45eddb5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions package.json
Expand Up @@ -130,6 +130,11 @@
"default": true,
"description": "Automatically handle spawning of elixir-sense servers for each folder in the workspace"
},
"elixir.command": {
"type": "string",
"default": "elixir",
"description": "Command to be run for launching the elixir_sense server providing intellisense features. Defaults to 'elixir'"
},
"elixir.elixirEnv": {
"type": "string",
"default": "dev",
Expand Down
5 changes: 3 additions & 2 deletions src/elixirMain.ts
Expand Up @@ -48,7 +48,7 @@ export function activate(ctx: vscode.ExtensionContext) {
}
});
} else {
this.elixirServer = new ElixirServer();
this.elixirServer = new ElixirServer(elixirSetting.command);
this.elixirServer.start();
ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(ELIXIR_MODE, new ElixirAutocomplete(this.elixirServer), '.'));
ctx.subscriptions.push(vscode.languages.registerDefinitionProvider(ELIXIR_MODE, new ElixirDefinitionProvider(this.elixirServer)));
Expand Down Expand Up @@ -83,7 +83,8 @@ function startElixirSenseServerForWorkspaceFolder(workspaceFolder: vscode.Worksp
return;
}
let subscriptions;
const elixirSenseServer = new ElixirSenseServerProcess(projectPath, (host, port, authToken) => {
const elixirSetting = vscode.workspace.getConfiguration('elixir');
const elixirSenseServer = new ElixirSenseServerProcess(elixirSetting.command, projectPath, (host, port, authToken) => {
const elixirSenseClient = new ElixirSenseClient(host, port, authToken, env, projectPath);
elixirSenseClients[projectPath] = elixirSenseClient;
const autoCompleteProvider = new ElixirSenseAutocompleteProvider(elixirSenseClient);
Expand Down
4 changes: 1 addition & 3 deletions src/elixirSenseServerProcess.ts
Expand Up @@ -12,10 +12,8 @@ export class ElixirSenseServerProcess {
ready;
proc;
args;
command;

constructor(public projectPath: string, public onTcpServerReady) {
this.command = 'elixir';
constructor(private command: string, public projectPath: string, public onTcpServerReady) {
const extensionPath = vscode.extensions.getExtension('mjmcloug.vscode-elixir').extensionPath;
this.args = [path.join(extensionPath, 'elixir_sense/run.exs')];
this.proc = null;
Expand Down
3 changes: 1 addition & 2 deletions src/elixirServer.ts
Expand Up @@ -4,7 +4,6 @@ import * as vscode from 'vscode';

export class ElixirServer {
p: cp.ChildProcess;
command: string;
args: string[];
env: string;
busy: boolean;
Expand All @@ -13,7 +12,7 @@ export class ElixirServer {
lastRequestType: string;
resultCallback: (result: string) => void;

constructor() {
constructor(private command: string) {
const extensionPath: string = vscode.extensions.getExtension('mjmcloug.vscode-elixir').extensionPath;
this.command = 'elixir';
this.args = [path.join(extensionPath, 'alchemist-server/run.exs')];
Expand Down

0 comments on commit 45eddb5

Please sign in to comment.