mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(editor): Update config sent to language server (#6724)
Syncs up the options from the language server `Options` struct with the values that the extension supplies. I tend to avoid `toJSON` because it will be used by `JSON.stringify` when called and it's not well known. There's no reason that `LanguageServerConfig` and `Config` have to both exist, but I think two types is easier to understand. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
41a6ad63b6
commit
1bcd707c8c
2 changed files with 12 additions and 13 deletions
|
|
@ -5,9 +5,9 @@ export class ConfigService implements Config, IDisposable {
|
|||
private static readonly _namespace = 'oxc';
|
||||
private readonly _disposables: IDisposable[] = [];
|
||||
private _inner: WorkspaceConfiguration;
|
||||
private _runTrigger: 'onSave' | 'onType';
|
||||
private _runTrigger: Trigger;
|
||||
private _enable: boolean;
|
||||
private _trace: 'off' | 'messages' | 'verbose';
|
||||
private _trace: TraceLevel;
|
||||
private _configPath: string;
|
||||
private _binPath: string | undefined;
|
||||
|
||||
|
|
@ -30,10 +30,6 @@ export class ConfigService implements Config, IDisposable {
|
|||
this._disposables.push(disposeChangeListener);
|
||||
}
|
||||
|
||||
get rawConfig(): WorkspaceConfiguration {
|
||||
return this._inner;
|
||||
}
|
||||
|
||||
get runTrigger(): Trigger {
|
||||
return this._runTrigger;
|
||||
}
|
||||
|
|
@ -106,13 +102,11 @@ export class ConfigService implements Config, IDisposable {
|
|||
}
|
||||
}
|
||||
|
||||
public toJSON(): Config {
|
||||
public toLanguageServerConfig(): LanguageServerConfig {
|
||||
return {
|
||||
runTrigger: this.runTrigger,
|
||||
run: this.runTrigger,
|
||||
enable: this.enable,
|
||||
trace: this.trace,
|
||||
configPath: this.configPath,
|
||||
binPath: this.binPath,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +114,12 @@ export class ConfigService implements Config, IDisposable {
|
|||
type Trigger = 'onSave' | 'onType';
|
||||
type TraceLevel = 'off' | 'messages' | 'verbose';
|
||||
|
||||
interface LanguageServerConfig {
|
||||
configPath: string;
|
||||
enable: boolean;
|
||||
run: Trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* See `"contributes.configuration"` in `package.json`
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -136,7 +136,6 @@ export async function activate(context: ExtensionContext) {
|
|||
// If the extension is launched in debug mode then the debug server options are used
|
||||
// Otherwise the run options are used
|
||||
// Options to control the language client
|
||||
let clientConfig: any = JSON.parse(JSON.stringify(config.rawConfig));
|
||||
let clientOptions: LanguageClientOptions = {
|
||||
// Register the server for plain text documents
|
||||
documentSelector: [
|
||||
|
|
@ -155,7 +154,7 @@ export async function activate(context: ExtensionContext) {
|
|||
fileEvents: workspace.createFileSystemWatcher('**/.clientrc'),
|
||||
},
|
||||
initializationOptions: {
|
||||
settings: clientConfig,
|
||||
settings: config.toLanguageServerConfig(),
|
||||
},
|
||||
outputChannel,
|
||||
traceOutputChannel,
|
||||
|
|
@ -200,7 +199,7 @@ export async function activate(context: ExtensionContext) {
|
|||
|
||||
myStatusBarItem.backgroundColor = bgColor;
|
||||
}
|
||||
updateStatsBar(clientConfig.enable);
|
||||
updateStatsBar(config.enable);
|
||||
client.start();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue