mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Send the config from the client
This commit is contained in:
parent
019f269a0a
commit
a9dd442733
2 changed files with 28 additions and 24 deletions
|
@ -5,6 +5,31 @@ import { Config } from './config';
|
|||
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
|
||||
import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
|
||||
|
||||
export function configToOptions(config: Config): object {
|
||||
return {
|
||||
publishDecorations: !config.highlightingSemanticTokens,
|
||||
lruCapacity: config.lruCapacity,
|
||||
|
||||
inlayHintsType: config.inlayHints.typeHints,
|
||||
inlayHintsParameter: config.inlayHints.parameterHints,
|
||||
inlayHintsChaining: config.inlayHints.chainingHints,
|
||||
inlayHintsMaxLength: config.inlayHints.maxLength,
|
||||
|
||||
cargoWatchEnable: config.cargoWatchOptions.enable,
|
||||
cargoWatchArgs: config.cargoWatchOptions.arguments,
|
||||
cargoWatchCommand: config.cargoWatchOptions.command,
|
||||
cargoWatchAllTargets: config.cargoWatchOptions.allTargets,
|
||||
|
||||
excludeGlobs: config.excludeGlobs,
|
||||
useClientWatching: config.useClientWatching,
|
||||
featureFlags: config.featureFlags,
|
||||
withSysroot: config.withSysroot,
|
||||
cargoFeatures: config.cargoFeatures,
|
||||
rustfmtArgs: config.rustfmtArgs,
|
||||
vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function createClient(config: Config, serverPath: string): Promise<lc.LanguageClient> {
|
||||
// '.' Is the fallback if no folder is open
|
||||
// TODO?: Workspace folders support Uri's (eg: file://test.txt).
|
||||
|
@ -22,32 +47,10 @@ export async function createClient(config: Config, serverPath: string): Promise<
|
|||
const traceOutputChannel = vscode.window.createOutputChannel(
|
||||
'Rust Analyzer Language Server Trace',
|
||||
);
|
||||
const cargoWatchOpts = config.cargoWatchOptions;
|
||||
|
||||
const clientOptions: lc.LanguageClientOptions = {
|
||||
documentSelector: [{ scheme: 'file', language: 'rust' }],
|
||||
initializationOptions: {
|
||||
publishDecorations: !config.highlightingSemanticTokens,
|
||||
lruCapacity: config.lruCapacity,
|
||||
|
||||
inlayHintsType: config.inlayHints.typeHints,
|
||||
inlayHintsParameter: config.inlayHints.parameterHints,
|
||||
inlayHintsChaining: config.inlayHints.chainingHints,
|
||||
inlayHintsMaxLength: config.inlayHints.maxLength,
|
||||
|
||||
cargoWatchEnable: cargoWatchOpts.enable,
|
||||
cargoWatchArgs: cargoWatchOpts.arguments,
|
||||
cargoWatchCommand: cargoWatchOpts.command,
|
||||
cargoWatchAllTargets: cargoWatchOpts.allTargets,
|
||||
|
||||
excludeGlobs: config.excludeGlobs,
|
||||
useClientWatching: config.useClientWatching,
|
||||
featureFlags: config.featureFlags,
|
||||
withSysroot: config.withSysroot,
|
||||
cargoFeatures: config.cargoFeatures,
|
||||
rustfmtArgs: config.rustfmtArgs,
|
||||
vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null,
|
||||
},
|
||||
initializationOptions: configToOptions(config),
|
||||
traceOutputChannel,
|
||||
middleware: {
|
||||
// Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as vscode from 'vscode';
|
|||
import * as lc from 'vscode-languageclient';
|
||||
|
||||
import { Config } from './config';
|
||||
import { createClient } from './client';
|
||||
import { createClient, configToOptions } from './client';
|
||||
import { isRustEditor, RustEditor } from './util';
|
||||
|
||||
export class Ctx {
|
||||
|
@ -20,6 +20,7 @@ export class Ctx {
|
|||
const res = new Ctx(config, extCtx, client, serverPath);
|
||||
res.pushCleanup(client.start());
|
||||
await client.onReady();
|
||||
client.onRequest('workspace/configuration', _ => [configToOptions(config)]);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue