@@ -730,6 +730,12 @@ enum RatomlFile {
730
730
Crate ( LocalConfigInput ) ,
731
731
}
732
732
733
+ #[ derive( Clone , Debug ) ]
734
+ struct ClientInfo {
735
+ name : String ,
736
+ version : Option < Version > ,
737
+ }
738
+
733
739
#[ derive( Clone ) ]
734
740
pub struct Config {
735
741
/// Projects that have a Cargo.toml or a rust-project.json in a
@@ -744,7 +750,7 @@ pub struct Config {
744
750
caps : ClientCapabilities ,
745
751
root_path : AbsPathBuf ,
746
752
snippets : Vec < Snippet > ,
747
- visual_studio_code_version : Option < Version > ,
753
+ client_info : Option < ClientInfo > ,
748
754
749
755
default_config : & ' static DefaultConfigData ,
750
756
/// Config node that obtains its initial value during the server initialization and
@@ -777,7 +783,7 @@ impl fmt::Debug for Config {
777
783
. field ( "caps" , & self . caps )
778
784
. field ( "root_path" , & self . root_path )
779
785
. field ( "snippets" , & self . snippets )
780
- . field ( "visual_studio_code_version " , & self . visual_studio_code_version )
786
+ . field ( "client_info " , & self . client_info )
781
787
. field ( "client_config" , & self . client_config )
782
788
. field ( "user_config" , & self . user_config )
783
789
. field ( "ratoml_file" , & self . ratoml_file )
@@ -1335,7 +1341,7 @@ impl Config {
1335
1341
root_path : AbsPathBuf ,
1336
1342
caps : lsp_types:: ClientCapabilities ,
1337
1343
workspace_roots : Vec < AbsPathBuf > ,
1338
- visual_studio_code_version : Option < Version > ,
1344
+ client_info : Option < lsp_types :: ClientInfo > ,
1339
1345
) -> Self {
1340
1346
static DEFAULT_CONFIG_DATA : OnceLock < & ' static DefaultConfigData > = OnceLock :: new ( ) ;
1341
1347
@@ -1346,7 +1352,10 @@ impl Config {
1346
1352
root_path,
1347
1353
snippets : Default :: default ( ) ,
1348
1354
workspace_roots,
1349
- visual_studio_code_version,
1355
+ client_info : client_info. map ( |it| ClientInfo {
1356
+ name : it. name ,
1357
+ version : it. version . as_deref ( ) . map ( Version :: parse) . and_then ( Result :: ok) ,
1358
+ } ) ,
1350
1359
client_config : ( FullConfigInput :: default ( ) , ConfigErrors ( vec ! [ ] ) ) ,
1351
1360
default_config : DEFAULT_CONFIG_DATA . get_or_init ( || Box :: leak ( Box :: default ( ) ) ) ,
1352
1361
source_root_parent_map : Arc :: new ( FxHashMap :: default ( ) ) ,
@@ -1446,9 +1455,11 @@ impl Config {
1446
1455
limit : self . completion_limit ( source_root) . to_owned ( ) ,
1447
1456
enable_term_search : self . completion_termSearch_enable ( source_root) . to_owned ( ) ,
1448
1457
term_search_fuel : self . completion_termSearch_fuel ( source_root) . to_owned ( ) as u64 ,
1449
- fields_to_resolve : CompletionFieldsToResolve :: from_client_capabilities (
1450
- & client_capability_fields,
1451
- ) ,
1458
+ fields_to_resolve : if self . client_is_helix ( ) || self . client_is_neovim ( ) {
1459
+ CompletionFieldsToResolve :: empty ( )
1460
+ } else {
1461
+ CompletionFieldsToResolve :: from_client_capabilities ( & client_capability_fields)
1462
+ } ,
1452
1463
}
1453
1464
}
1454
1465
@@ -2163,7 +2174,18 @@ impl Config {
2163
2174
// VSCode is our reference implementation, so we allow ourselves to work around issues by
2164
2175
// special casing certain versions
2165
2176
pub fn visual_studio_code_version ( & self ) -> Option < & Version > {
2166
- self . visual_studio_code_version . as_ref ( )
2177
+ self . client_info
2178
+ . as_ref ( )
2179
+ . filter ( |it| it. name . starts_with ( "Visual Studio Code" ) )
2180
+ . and_then ( |it| it. version . as_ref ( ) )
2181
+ }
2182
+
2183
+ pub fn client_is_helix ( & self ) -> bool {
2184
+ self . client_info . as_ref ( ) . map ( |it| it. name == "helix" ) . unwrap_or_default ( )
2185
+ }
2186
+
2187
+ pub fn client_is_neovim ( & self ) -> bool {
2188
+ self . client_info . as_ref ( ) . map ( |it| it. name == "Neovim" ) . unwrap_or_default ( )
2167
2189
}
2168
2190
}
2169
2191
// Deserialization definitions
0 commit comments