1- use std:: { env, fs} ;
1+ use std:: { borrow :: Cow , env, fs} ;
22use zed_extension_api:: { self as zed, Result } ;
33
44const SERVER_PATH : & str = "node_modules/.bin/rescript-language-server" ;
@@ -13,11 +13,14 @@ impl ReScriptExtension {
1313 fs:: metadata ( SERVER_PATH ) . map_or ( false , |stat| stat. is_file ( ) )
1414 }
1515
16- fn server_script_path ( & mut self , server_id : & zed:: LanguageServerId ) -> Result < String > {
16+ fn server_script_path (
17+ & mut self ,
18+ server_id : & zed:: LanguageServerId ,
19+ ) -> Result < Cow < ' static , str > > {
1720 let server_exists = self . server_exists ( ) ;
1821 self . did_find_server = true ;
1922 if self . did_find_server && server_exists {
20- return Ok ( SERVER_PATH . to_string ( ) ) ;
23+ return Ok ( SERVER_PATH . into ( ) ) ;
2124 }
2225
2326 zed:: set_language_server_installation_status (
@@ -51,7 +54,8 @@ impl ReScriptExtension {
5154 }
5255
5356 self . did_find_server = true ;
54- Ok ( SERVER_PATH . to_string ( ) )
57+
58+ Ok ( SERVER_PATH . into ( ) )
5559 }
5660}
5761
@@ -68,12 +72,13 @@ impl zed::Extension for ReScriptExtension {
6872 _worktree : & zed:: Worktree ,
6973 ) -> Result < zed:: Command > {
7074 let server_path = self . server_script_path ( server_id) ?;
75+
7176 Ok ( zed:: Command {
7277 command : zed:: node_binary_path ( ) ?,
7378 args : vec ! [
7479 env:: current_dir( )
7580 . unwrap( )
76- . join( & server_path)
81+ . join( server_path. as_ref ( ) )
7782 . to_string_lossy( )
7883 . to_string( ) ,
7984 "--stdio" . to_string( ) ,
0 commit comments