From a9dd4427333d410bebf8e0923d5907b2a31efb50 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 20 Mar 2020 00:42:18 +0200 Subject: Send the config from the client --- editors/code/src/client.ts | 49 ++++++++++++++++++++++++---------------------- editors/code/src/ctx.ts | 3 ++- 2 files changed, 28 insertions(+), 24 deletions(-) (limited to 'editors/code') diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 98f2f232f..0d0832c44 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -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 { // '.' 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 diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 84c170ea8..934638c6d 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -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; } -- cgit v1.2.3