11use std:: { env, fs} ;
2- use zed:: {
3- serde_json:: { self , Value } ,
4- settings:: LspSettings ,
5- } ;
62use zed_extension_api:: { self as zed, Result } ;
73
8- const SERVER_PATH : & str = "node_modules/@rescript/ language-server/out/cli.js " ;
4+ const SERVER_PATH : & str = "node_modules/.bin/rescript- language-server" ;
95const PACKAGE_NAME : & str = "@rescript/language-server" ;
106
117struct ReScriptExtension {
@@ -19,6 +15,7 @@ impl ReScriptExtension {
1915
2016 fn server_script_path ( & mut self , server_id : & zed:: LanguageServerId ) -> Result < String > {
2117 let server_exists = self . server_exists ( ) ;
18+ self . did_find_server = true ;
2219 if self . did_find_server && server_exists {
2320 return Ok ( SERVER_PATH . to_string ( ) ) ;
2421 }
@@ -84,30 +81,6 @@ impl zed::Extension for ReScriptExtension {
8481 env : Default :: default ( ) ,
8582 } )
8683 }
87-
88- fn language_server_workspace_configuration (
89- & mut self ,
90- server_id : & zed:: LanguageServerId ,
91- worktree : & zed:: Worktree ,
92- ) -> Result < Option < Value > > {
93- // @rescript/language-server expects workspace didChangeConfiguration notification
94- // params to be the same as lsp initialization_options
95- let initialization_options = LspSettings :: for_worktree ( server_id. as_ref ( ) , worktree) ?
96- . initialization_options
97- . clone ( )
98- . unwrap_or_default ( ) ;
99-
100- Ok ( Some ( match initialization_options. clone ( ) . as_object_mut ( ) {
101- Some ( op) => {
102- // @rescript/language-server requests workspace configuration
103- // for the `resLS` section, so we have to nest
104- // another copy of initialization_options there
105- op. insert ( "rescriptLS" . into ( ) , initialization_options) ;
106- serde_json:: to_value ( op) . unwrap_or_default ( )
107- }
108- None => initialization_options,
109- } ) )
110- }
11184}
11285
11386zed:: register_extension!( ReScriptExtension ) ;
0 commit comments