@@ -730,6 +730,12 @@ enum RatomlFile {
730730 Crate ( LocalConfigInput ) ,
731731}
732732
733+ #[ derive( Clone , Debug ) ]
734+ struct ClientInfo {
735+ name : String ,
736+ version : Option < Version > ,
737+ }
738+
733739#[ derive( Clone ) ]
734740pub struct Config {
735741 /// Projects that have a Cargo.toml or a rust-project.json in a
@@ -744,7 +750,7 @@ pub struct Config {
744750 caps : ClientCapabilities ,
745751 root_path : AbsPathBuf ,
746752 snippets : Vec < Snippet > ,
747- visual_studio_code_version : Option < Version > ,
753+ client_info : Option < ClientInfo > ,
748754
749755 default_config : & ' static DefaultConfigData ,
750756 /// Config node that obtains its initial value during the server initialization and
@@ -777,7 +783,7 @@ impl fmt::Debug for Config {
777783 . field ( "caps" , & self . caps )
778784 . field ( "root_path" , & self . root_path )
779785 . field ( "snippets" , & self . snippets )
780- . field ( "visual_studio_code_version " , & self . visual_studio_code_version )
786+ . field ( "client_info " , & self . client_info )
781787 . field ( "client_config" , & self . client_config )
782788 . field ( "user_config" , & self . user_config )
783789 . field ( "ratoml_file" , & self . ratoml_file )
@@ -1335,7 +1341,7 @@ impl Config {
13351341 root_path : AbsPathBuf ,
13361342 caps : lsp_types:: ClientCapabilities ,
13371343 workspace_roots : Vec < AbsPathBuf > ,
1338- visual_studio_code_version : Option < Version > ,
1344+ client_info : Option < lsp_types :: ClientInfo > ,
13391345 ) -> Self {
13401346 static DEFAULT_CONFIG_DATA : OnceLock < & ' static DefaultConfigData > = OnceLock :: new ( ) ;
13411347
@@ -1346,7 +1352,10 @@ impl Config {
13461352 root_path,
13471353 snippets : Default :: default ( ) ,
13481354 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+ } ) ,
13501359 client_config : ( FullConfigInput :: default ( ) , ConfigErrors ( vec ! [ ] ) ) ,
13511360 default_config : DEFAULT_CONFIG_DATA . get_or_init ( || Box :: leak ( Box :: default ( ) ) ) ,
13521361 source_root_parent_map : Arc :: new ( FxHashMap :: default ( ) ) ,
@@ -1446,9 +1455,11 @@ impl Config {
14461455 limit : self . completion_limit ( source_root) . to_owned ( ) ,
14471456 enable_term_search : self . completion_termSearch_enable ( source_root) . to_owned ( ) ,
14481457 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+ } ,
14521463 }
14531464 }
14541465
@@ -2163,7 +2174,18 @@ impl Config {
21632174 // VSCode is our reference implementation, so we allow ourselves to work around issues by
21642175 // special casing certain versions
21652176 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 ( )
21672189 }
21682190}
21692191// Deserialization definitions
0 commit comments