@@ -16,20 +16,33 @@ use serde::Deserialize;
1616#[ derive( Debug , Clone ) ]
1717pub struct Config {
1818 pub client_caps : ClientCapsConfig ,
19+
20+ pub with_sysroot : bool ,
1921 pub publish_diagnostics : bool ,
22+ pub lru_capacity : Option < usize > ,
23+ pub proc_macro_srv : Option < String > ,
24+ pub files : FilesConfig ,
2025 pub notifications : NotificationsConfig ,
26+
27+ pub cargo : CargoConfig ,
28+ pub rustfmt : RustfmtConfig ,
29+ pub check : Option < FlycheckConfig > ,
30+
2131 pub inlay_hints : InlayHintsConfig ,
2232 pub completion : CompletionConfig ,
2333 pub call_info_full : bool ,
24- pub rustfmt : RustfmtConfig ,
25- pub check : Option < FlycheckConfig > ,
26- pub vscode_lldb : bool ,
27- pub proc_macro_srv : Option < String > ,
28- pub lru_capacity : Option < usize > ,
29- pub use_client_watching : bool ,
30- pub exclude_globs : Vec < String > ,
31- pub cargo : CargoConfig ,
32- pub with_sysroot : bool ,
34+ }
35+
36+ #[ derive( Debug , Clone ) ]
37+ pub struct FilesConfig {
38+ pub watcher : FilesWatcher ,
39+ pub exclude : Vec < String > ,
40+ }
41+
42+ #[ derive( Debug , Clone ) ]
43+ pub enum FilesWatcher {
44+ Client ,
45+ Notify ,
3346}
3447
3548#[ derive( Debug , Clone ) ]
@@ -59,12 +72,26 @@ pub struct ClientCapsConfig {
5972impl Default for Config {
6073 fn default ( ) -> Self {
6174 Config {
75+ client_caps : ClientCapsConfig :: default ( ) ,
76+
77+ with_sysroot : true ,
6278 publish_diagnostics : true ,
79+ lru_capacity : None ,
80+ proc_macro_srv : None ,
81+ files : FilesConfig { watcher : FilesWatcher :: Notify , exclude : Vec :: new ( ) } ,
6382 notifications : NotificationsConfig {
6483 workspace_loaded : true ,
6584 cargo_toml_not_found : true ,
6685 } ,
67- client_caps : ClientCapsConfig :: default ( ) ,
86+
87+ cargo : CargoConfig :: default ( ) ,
88+ rustfmt : RustfmtConfig :: Rustfmt { extra_args : Vec :: new ( ) } ,
89+ check : Some ( FlycheckConfig :: CargoCommand {
90+ command : "check" . to_string ( ) ,
91+ all_targets : true ,
92+ extra_args : Vec :: new ( ) ,
93+ } ) ,
94+
6895 inlay_hints : InlayHintsConfig {
6996 type_hints : true ,
7097 parameter_hints : true ,
@@ -77,19 +104,6 @@ impl Default for Config {
77104 add_call_argument_snippets : true ,
78105 } ,
79106 call_info_full : true ,
80- rustfmt : RustfmtConfig :: Rustfmt { extra_args : Vec :: new ( ) } ,
81- check : Some ( FlycheckConfig :: CargoCommand {
82- command : "check" . to_string ( ) ,
83- all_targets : true ,
84- extra_args : Vec :: new ( ) ,
85- } ) ,
86- vscode_lldb : false ,
87- proc_macro_srv : None ,
88- lru_capacity : None ,
89- use_client_watching : false ,
90- exclude_globs : Vec :: new ( ) ,
91- cargo : CargoConfig :: default ( ) ,
92- with_sysroot : true ,
93107 }
94108 }
95109}
@@ -103,45 +117,44 @@ impl Config {
103117 * self = Default :: default ( ) ;
104118 self . client_caps = client_caps;
105119
106- set ( value, "/excludeGlobs " , & mut self . exclude_globs ) ;
107- set ( value, "/useClientWatching " , & mut self . use_client_watching ) ;
120+ set ( value, "/withSysroot " , & mut self . with_sysroot ) ;
121+ set ( value, "/featureFlags/lsp.diagnostics " , & mut self . publish_diagnostics ) ;
108122 set ( value, "/lruCapacity" , & mut self . lru_capacity ) ;
123+ if let Some ( watcher) = get :: < String > ( value, "/files/watcher" ) {
124+ self . files . watcher = match watcher. as_str ( ) {
125+ "client" => FilesWatcher :: Client ,
126+ "notify" | _ => FilesWatcher :: Notify ,
127+ }
128+ }
129+ set ( value, "/notifications/workspaceLoaded" , & mut self . notifications . workspace_loaded ) ;
130+ set ( value, "/notifications/cargoTomlNotFound" , & mut self . notifications . cargo_toml_not_found ) ;
109131
110- set ( value, "/inlayHintsType" , & mut self . inlay_hints . type_hints ) ;
111- set ( value, "/inlayHintsParameter" , & mut self . inlay_hints . parameter_hints ) ;
112- set ( value, "/inlayHintsChaining" , & mut self . inlay_hints . chaining_hints ) ;
113- set ( value, "/inlayHintsMaxLength" , & mut self . inlay_hints . max_length ) ;
114-
115- if let Some ( false ) = get ( value, "cargo_watch_enable" ) {
132+ set ( value, "/cargo/noDefaultFeatures" , & mut self . cargo . no_default_features ) ;
133+ set ( value, "/cargo/allFeatures" , & mut self . cargo . all_features ) ;
134+ set ( value, "/cargo/features" , & mut self . cargo . features ) ;
135+ set ( value, "/cargo/loadOutDirsFromCheck" , & mut self . cargo . load_out_dirs_from_check ) ;
136+ if let RustfmtConfig :: Rustfmt { extra_args } = & mut self . rustfmt {
137+ set ( value, "/rustfmt/extraArgs" , extra_args) ;
138+ }
139+ if let Some ( false ) = get ( value, "/checkOnSave/enable" ) {
116140 self . check = None
117141 } else {
118142 if let Some ( FlycheckConfig :: CargoCommand { command, extra_args, all_targets } ) = & mut self . check
119143 {
120- set ( value, "/cargoWatchArgs " , extra_args) ;
121- set ( value, "/cargoWatchCommand " , command) ;
122- set ( value, "/cargoWatchAllTargets " , all_targets) ;
144+ set ( value, "/checkOnSave/extraArgs " , extra_args) ;
145+ set ( value, "/checkOnSave/command " , command) ;
146+ set ( value, "/checkOnSave/allTargets " , all_targets) ;
123147 }
124148 } ;
125149
126- set ( value, "/withSysroot" , & mut self . with_sysroot ) ;
127- if let RustfmtConfig :: Rustfmt { extra_args } = & mut self . rustfmt {
128- set ( value, "/rustfmtArgs" , extra_args) ;
129- }
130-
131- set ( value, "/cargoFeatures/noDefaultFeatures" , & mut self . cargo . no_default_features ) ;
132- set ( value, "/cargoFeatures/allFeatures" , & mut self . cargo . all_features ) ;
133- set ( value, "/cargoFeatures/features" , & mut self . cargo . features ) ;
134- set ( value, "/cargoFeatures/loadOutDirsFromCheck" , & mut self . cargo . load_out_dirs_from_check ) ;
135-
136- set ( value, "/vscodeLldb" , & mut self . vscode_lldb ) ;
137-
138- set ( value, "/featureFlags/lsp.diagnostics" , & mut self . publish_diagnostics ) ;
139- set ( value, "/featureFlags/notifications.workspace-loaded" , & mut self . notifications . workspace_loaded ) ;
140- set ( value, "/featureFlags/notifications.cargo-toml-not-found" , & mut self . notifications . cargo_toml_not_found ) ;
141- set ( value, "/featureFlags/completion.enable-postfix" , & mut self . completion . enable_postfix_completions ) ;
142- set ( value, "/featureFlags/completion.insertion.add-call-parenthesis" , & mut self . completion . add_call_parenthesis ) ;
143- set ( value, "/featureFlags/completion.insertion.add-argument-snippets" , & mut self . completion . add_call_argument_snippets ) ;
144- set ( value, "/featureFlags/call-info.full" , & mut self . call_info_full ) ;
150+ set ( value, "/inlayHints/typeHints" , & mut self . inlay_hints . type_hints ) ;
151+ set ( value, "/inlayHints/parameterHints" , & mut self . inlay_hints . parameter_hints ) ;
152+ set ( value, "/inlayHints/chainingHints" , & mut self . inlay_hints . chaining_hints ) ;
153+ set ( value, "/inlayHints/maxLength" , & mut self . inlay_hints . max_length ) ;
154+ set ( value, "/completion/postfix/enable" , & mut self . completion . enable_postfix_completions ) ;
155+ set ( value, "/completion/addCallParenthesis" , & mut self . completion . add_call_parenthesis ) ;
156+ set ( value, "/completion/addCallArgumentSnippets" , & mut self . completion . add_call_argument_snippets ) ;
157+ set ( value, "/callInfo/full" , & mut self . call_info_full ) ;
145158
146159 log:: info!( "Config::update() = {:#?}" , self ) ;
147160
0 commit comments