fix: resolve TypeScript LSP initialization failure

typescript-language-server requires a valid TypeScript installation to
function. Previously, no initializationOptions were sent during the LSP
initialize request, causing the server to fail with:

  'Could not find a valid TypeScript installation. Please ensure that
  the typescript dependency is installed in the workspace or that a
  valid tsserver.path is specified.'

This fix:
- Adds initializationOptions.tsserver.path resolution that searches for
  TypeScript in: workspace node_modules, global npm install, and npx cache
- Wires initialization_options into the LSP startup flow via LSPServerType
- Updates the install step to proactively install TypeScript globally if
  not found locally
This commit is contained in:
Ryan Ward
2026-07-16 16:58:47 -05:00
parent 0db915712f
commit 4aa2c0d685
3 changed files with 158 additions and 1 deletions
+10 -1
View File
@@ -205,7 +205,16 @@ impl LspServerConfig {
custom_binary_config
);
let params = default_init_params(&self.initial_workspace, self.client_name)?;
let mut params = default_init_params(&self.initial_workspace, self.client_name)?;
// Resolve server-specific initialization options (e.g., tsserver.path for TypeScript)
let init_options = self
.server_type
.initialization_options(&self.initial_workspace, executor.path_env_var())
.await;
if let Some(options) = init_options {
params.initialization_options = Some(options);
}
Ok(ResolvedLspCommand { command, params })
}