@@ -5,6 +5,31 @@ import { Config } from './config';
55import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed' ;
66import { SemanticTokensFeature , DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed' ;
77
8+ export function configToOptions ( config : Config ) : object {
9+ return {
10+ publishDecorations : ! config . highlightingSemanticTokens ,
11+ lruCapacity : config . lruCapacity ,
12+
13+ inlayHintsType : config . inlayHints . typeHints ,
14+ inlayHintsParameter : config . inlayHints . parameterHints ,
15+ inlayHintsChaining : config . inlayHints . chainingHints ,
16+ inlayHintsMaxLength : config . inlayHints . maxLength ,
17+
18+ cargoWatchEnable : config . cargoWatchOptions . enable ,
19+ cargoWatchArgs : config . cargoWatchOptions . arguments ,
20+ cargoWatchCommand : config . cargoWatchOptions . command ,
21+ cargoWatchAllTargets : config . cargoWatchOptions . allTargets ,
22+
23+ excludeGlobs : config . excludeGlobs ,
24+ useClientWatching : config . useClientWatching ,
25+ featureFlags : config . featureFlags ,
26+ withSysroot : config . withSysroot ,
27+ cargoFeatures : config . cargoFeatures ,
28+ rustfmtArgs : config . rustfmtArgs ,
29+ vscodeLldb : vscode . extensions . getExtension ( "vadimcn.vscode-lldb" ) != null ,
30+ } ;
31+ }
32+
833export async function createClient ( config : Config , serverPath : string ) : Promise < lc . LanguageClient > {
934 // '.' Is the fallback if no folder is open
1035 // TODO?: Workspace folders support Uri's (eg: file://test.txt).
@@ -22,32 +47,10 @@ export async function createClient(config: Config, serverPath: string): Promise<
2247 const traceOutputChannel = vscode . window . createOutputChannel (
2348 'Rust Analyzer Language Server Trace' ,
2449 ) ;
25- const cargoWatchOpts = config . cargoWatchOptions ;
2650
2751 const clientOptions : lc . LanguageClientOptions = {
2852 documentSelector : [ { scheme : 'file' , language : 'rust' } ] ,
29- initializationOptions : {
30- publishDecorations : ! config . highlightingSemanticTokens ,
31- lruCapacity : config . lruCapacity ,
32-
33- inlayHintsType : config . inlayHints . typeHints ,
34- inlayHintsParameter : config . inlayHints . parameterHints ,
35- inlayHintsChaining : config . inlayHints . chainingHints ,
36- inlayHintsMaxLength : config . inlayHints . maxLength ,
37-
38- cargoWatchEnable : cargoWatchOpts . enable ,
39- cargoWatchArgs : cargoWatchOpts . arguments ,
40- cargoWatchCommand : cargoWatchOpts . command ,
41- cargoWatchAllTargets : cargoWatchOpts . allTargets ,
42-
43- excludeGlobs : config . excludeGlobs ,
44- useClientWatching : config . useClientWatching ,
45- featureFlags : config . featureFlags ,
46- withSysroot : config . withSysroot ,
47- cargoFeatures : config . cargoFeatures ,
48- rustfmtArgs : config . rustfmtArgs ,
49- vscodeLldb : vscode . extensions . getExtension ( "vadimcn.vscode-lldb" ) != null ,
50- } ,
53+ initializationOptions : configToOptions ( config ) ,
5154 traceOutputChannel,
5255 middleware : {
5356 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576
0 commit comments