From ae11901dfabbaec670e126de2d422523ce0a5d98 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 20 Jun 2026 12:41:55 -0300 Subject: [PATCH] Forward LSP settings to ReScript server Return the configured Zed LSP settings as workspace configuration so server-specific options under rescript-language-server.settings reach the language server. --- README.md | 15 +++++++++++++-- src/rescript.rs | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 79d55b2..b105095 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,29 @@ This extension plugs in the following projects: - [tree-sitter-rescript](https://github.com/rescript-lang/tree-sitter-rescript) parser - [@rescript/language-server](https://github.com/rescript-lang/rescript-vscode) LSP +## How test the experimental server + +> TODO + ## Settings ```json "lsp": { "rescript-language-server": { + // Settings for stable server "initialization_options": { "extensionConfiguration": { "askToStartBuild": false } }, "settings": { - "version": "1.71.0-next-441959d.0" + "version": "1.71.0-next-441959d.0", + // Server settings for experimental server go inside `rescript` key + "rescript": { + "hover": { + "supportMarkdownLinks": true, + }, + }, } } }, @@ -26,7 +37,7 @@ This extension plugs in the following projects: `initialization_options` are passed to the language server when it is started. They can be used to configure the language server. See [extensionConfiguration](https://github.com/rescript-lang/rescript-vscode/blob/441959d1feeaaffc1a589687758b1fbe1f649e72/server/src/config.ts#L5-L29) -`settings` are specific to the Zed extension. +The `settings.version` are specific to the Zed extension. With `version` you can point to a specific npm version of the [@rescript/language-server](https://www.npmjs.com/package/@rescript/language-server?activeTab=versions). ## Developing diff --git a/src/rescript.rs b/src/rescript.rs index 9234f4e..3724675 100644 --- a/src/rescript.rs +++ b/src/rescript.rs @@ -118,8 +118,8 @@ impl zed::Extension for ReScriptExtension { ) -> Result { let server_path = self.server_script_path(server_id, worktree)?; - let current_dir = env::current_dir() - .map_err(|e| format!("failed to get current directory: {e}"))?; + let current_dir = + env::current_dir().map_err(|e| format!("failed to get current directory: {e}"))?; Ok(zed::Command { command: zed::node_binary_path()?, @@ -151,6 +151,17 @@ impl zed::Extension for ReScriptExtension { } }))) } + + fn language_server_workspace_configuration( + &mut self, + language_server_id: &zed::LanguageServerId, + worktree: &zed::Worktree, + ) -> Result> { + match zed::settings::LspSettings::for_worktree(language_server_id.as_ref(), worktree) { + Ok(LspSettings { settings, .. }) => Ok(settings), + Err(_) => Ok(None), + } + } } zed::register_extension!(ReScriptExtension);