-
Notifications
You must be signed in to change notification settings - Fork 161
Use the user's default toolchain #180
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
|
||
'use strict'; | ||
|
||
import { execSync } from 'child_process'; | ||
|
||
import { workspace, WorkspaceConfiguration } from 'vscode'; | ||
import { RevealOutputChannelOn } from 'vscode-languageclient'; | ||
|
||
|
@@ -58,15 +60,37 @@ export class RLSConfiguration { | |
this.revealOutputChannelOn = RLSConfiguration.readRevealOutputChannelOn(configuration); | ||
this.updateOnStartup = configuration.get<boolean>('rust-client.updateOnStartup', true); | ||
|
||
this.channel = configuration.get('rust-client.channel', 'nightly'); | ||
this.componentName = configuration.get('rust-client.rls-name', 'rls'); | ||
this.channel = configuration.get('rust-client.channel', 'default'); | ||
if (this.channel === 'default') { | ||
try { | ||
this.channel = RLSConfiguration.defaultChannel(this.rustupPath); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you move this code to rustup.rs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about moving it there but most of the code in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you're using |
||
|
||
this.componentName = configuration.get('rust-client.rls-name', 'rls-preview'); | ||
|
||
// Hidden options that are not exposed to the user | ||
this.rlsPath = configuration.get('rls.path', null); | ||
this.rlsRoot = configuration.get('rls.root', null); | ||
} | ||
|
||
private static readRevealOutputChannelOn(configuration: WorkspaceConfiguration) { | ||
const setting = configuration.get<string>('rust-client.revealOutputChannelOn', 'never'); | ||
return fromStringToRevealOutputChannelOn(setting); | ||
} | ||
|
||
private static defaultChannel(rustupPath: string): string { | ||
const stdout = execSync(rustupPath + ' toolchain list').toString(); | ||
const matches = stdout.match(/^(.*) \(default\)$/m); | ||
|
||
if (matches === null) { | ||
throw new Error('Unable to determine default toolchain'); | ||
} else if (matches.length !== 2) { | ||
throw new Error('Found unexpected number of default toolchains'); | ||
} | ||
|
||
return matches[1]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use
null
rather than"default"