11use std:: path:: PathBuf ;
22
33use super :: ClientCapabilities ;
4+ use lsp_types:: Url ;
45use serde:: { Deserialize , Serialize } ;
56use serde_json:: Value ;
67
7- #[ derive( Default , Clone , Debug , Serialize , Deserialize , Eq , PartialEq ) ]
8- #[ serde( rename_all = "camelCase" , default ) ]
8+ #[ derive( Clone , Debug , Serialize , Deserialize , Eq , PartialEq ) ]
9+ #[ serde( rename_all = "camelCase" ) ]
910/// Like the language server protocol, the initialize request is sent as the first request from the
1011/// client to the server. If the server receives a request or notification before the initialize
1112/// request it should act as follows:
@@ -22,18 +23,18 @@ pub struct InitializeBuild {
2223 /// Name of the client
2324 display_name : String ,
2425 /// The version of the client
25- #[ serde( skip_serializing_if = "String::is_empty" ) ]
26+ #[ serde( skip_serializing_if = "String::is_empty" , default ) ]
2627 version : String ,
2728 /// The BSP version that the client speaks
28- #[ serde( skip_serializing_if = "String::is_empty" ) ]
29+ #[ serde( skip_serializing_if = "String::is_empty" , default ) ]
2930 bsp_version : String ,
3031 /// The rootUri of the workspace
31- #[ serde( skip_serializing_if = "String::is_empty" ) ]
32- root_uri : String ,
32+ root_uri : Url ,
3333 /// The capabilities of the client
34+ #[ serde( default ) ]
3435 capabilities : ClientCapabilities ,
3536 /// Additional metadata about the client
36- #[ serde( skip_serializing_if = "Option::is_none" ) ]
37+ #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
3738 data : Option < Value > ,
3839}
3940
@@ -42,7 +43,7 @@ impl InitializeBuild {
4243 display_name : S ,
4344 version : S ,
4445 bsp_version : S ,
45- root_uri : S ,
46+ root_uri : Url ,
4647 capabilities : ClientCapabilities ,
4748 data : Value ,
4849 ) -> Self {
@@ -60,7 +61,7 @@ impl InitializeBuild {
6061 display_name : S ,
6162 version : S ,
6263 bsp_version : S ,
63- root_uri : S ,
64+ root_uri : Url ,
6465 capabilities : ClientCapabilities ,
6566 ) -> Self {
6667 Self {
@@ -99,14 +100,12 @@ impl InitializeBuild {
99100 }
100101
101102 /// Get a reference to the bsp initialize build params's root uri.
102- pub fn root_path ( & self ) -> Option < PathBuf > {
103- self . root_uri
104- . strip_prefix ( "file://" )
105- . map ( |s| PathBuf :: from ( s) )
103+ pub fn root_path ( & self ) -> PathBuf {
104+ self . root_uri . path ( ) . into ( )
106105 }
107106
108107 /// Set the bsp initialize build params's root uri.
109- pub fn set_root_uri ( & mut self , root_uri : String ) {
108+ pub fn set_root_uri ( & mut self , root_uri : Url ) {
110109 self . root_uri = root_uri;
111110 }
112111
0 commit comments