vtsls: Move all default configuration to workspace_configuration (#18259)
This fixes https://github.com/zed-industries/zed/issues/18014 by fixing the regression that was introduced in https://github.com/zed-industries/zed/pull/17757. In short: after digging into the `vtsls` code, it looks like it essentially doesn't need any `initialization_options`, it's all workspace configuration, since it tries to use the built-in settings from VS Code. I tested the completions, the inlay hints, the max memory - all of it now works after moving to `workspace_configuration`. Closes #18014. Release Notes: - Fixed `vtsls` being initialized the wrong way, which would mean the wrong options were used to enable completions or inlay hints.
This commit is contained in:
parent
6b56530a4a
commit
dbc325ea12
2 changed files with 96 additions and 40 deletions
|
@ -6,14 +6,14 @@ use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||||
use lsp::{CodeActionKind, LanguageServerBinary};
|
use lsp::{CodeActionKind, LanguageServerBinary};
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
use project::{lsp_store::language_server_settings, project_settings::BinarySettings};
|
use project::{lsp_store::language_server_settings, project_settings::BinarySettings};
|
||||||
use serde_json::{json, Value};
|
use serde_json::Value;
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use util::{maybe, ResultExt};
|
use util::{maybe, merge_json_value_into, ResultExt};
|
||||||
|
|
||||||
fn typescript_server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
fn typescript_server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
||||||
vec![server_path.into(), "--stdio".into()]
|
vec![server_path.into(), "--stdio".into()]
|
||||||
|
@ -212,11 +212,12 @@ impl LspAdapter for VtslsLspAdapter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn initialization_options(
|
async fn workspace_configuration(
|
||||||
self: Arc<Self>,
|
self: Arc<Self>,
|
||||||
adapter: &Arc<dyn LspAdapterDelegate>,
|
delegate: &Arc<dyn LspAdapterDelegate>,
|
||||||
) -> Result<Option<serde_json::Value>> {
|
cx: &mut AsyncAppContext,
|
||||||
let tsdk_path = Self::tsdk_path(adapter).await;
|
) -> Result<Value> {
|
||||||
|
let tsdk_path = Self::tsdk_path(delegate).await;
|
||||||
let config = serde_json::json!({
|
let config = serde_json::json!({
|
||||||
"tsdk": tsdk_path,
|
"tsdk": tsdk_path,
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
@ -243,10 +244,13 @@ impl LspAdapter for VtslsLspAdapter {
|
||||||
"enumMemberValues": {
|
"enumMemberValues": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"tsserver": {
|
||||||
|
"maxTsServerMemory": 8092
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(Some(json!({
|
let mut default_workspace_configuration = serde_json::json!({
|
||||||
"typescript": config,
|
"typescript": config,
|
||||||
"javascript": config,
|
"javascript": config,
|
||||||
"vtsls": {
|
"vtsls": {
|
||||||
|
@ -258,33 +262,18 @@ impl LspAdapter for VtslsLspAdapter {
|
||||||
},
|
},
|
||||||
"autoUseWorkspaceTsdk": true
|
"autoUseWorkspaceTsdk": true
|
||||||
}
|
}
|
||||||
})))
|
});
|
||||||
}
|
|
||||||
|
|
||||||
async fn workspace_configuration(
|
|
||||||
self: Arc<Self>,
|
|
||||||
delegate: &Arc<dyn LspAdapterDelegate>,
|
|
||||||
cx: &mut AsyncAppContext,
|
|
||||||
) -> Result<Value> {
|
|
||||||
let override_options = cx.update(|cx| {
|
let override_options = cx.update(|cx| {
|
||||||
language_server_settings(delegate.as_ref(), &SERVER_NAME, cx)
|
language_server_settings(delegate.as_ref(), &SERVER_NAME, cx)
|
||||||
.and_then(|s| s.settings.clone())
|
.and_then(|s| s.settings.clone())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if let Some(options) = override_options {
|
if let Some(override_options) = override_options {
|
||||||
return Ok(options);
|
merge_json_value_into(override_options, &mut default_workspace_configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = serde_json::json!({
|
Ok(default_workspace_configuration)
|
||||||
"tsserver": {
|
|
||||||
"maxTsServerMemory": 8092
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(serde_json::json!({
|
|
||||||
"typescript": config,
|
|
||||||
"javascript": config
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn language_ids(&self) -> HashMap<String, String> {
|
fn language_ids(&self) -> HashMap<String, String> {
|
||||||
|
|
|
@ -68,11 +68,14 @@ Prettier will also be used for TypeScript files by default. To disable this:
|
||||||
Zed sets the following initialization options to make the language server send back inlay hints
|
Zed sets the following initialization options to make the language server send back inlay hints
|
||||||
(that is, when Zed has inlay hints enabled in the settings).
|
(that is, when Zed has inlay hints enabled in the settings).
|
||||||
|
|
||||||
You can override these settings in your configuration file:
|
You can override these settings in your Zed settings file.
|
||||||
|
|
||||||
|
When using `typescript-language-server`:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"lsp": {
|
{
|
||||||
"$LANGUAGE_SERVER_NAME": {
|
"lsp": {
|
||||||
|
"typescript-language-server": {
|
||||||
"initialization_options": {
|
"initialization_options": {
|
||||||
"preferences": {
|
"preferences": {
|
||||||
"includeInlayParameterNameHints": "all",
|
"includeInlayParameterNameHints": "all",
|
||||||
|
@ -82,7 +85,8 @@ You can override these settings in your configuration file:
|
||||||
"includeInlayVariableTypeHintsWhenTypeMatchesName": true,
|
"includeInlayVariableTypeHintsWhenTypeMatchesName": true,
|
||||||
"includeInlayPropertyDeclarationTypeHints": true,
|
"includeInlayPropertyDeclarationTypeHints": true,
|
||||||
"includeInlayFunctionLikeReturnTypeHints": true,
|
"includeInlayFunctionLikeReturnTypeHints": true,
|
||||||
"includeInlayEnumMemberValueHints": true,
|
"includeInlayEnumMemberValueHints": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +95,69 @@ You can override these settings in your configuration file:
|
||||||
|
|
||||||
See [typescript-language-server inlayhints documentation](https://github.com/typescript-language-server/typescript-language-server?tab=readme-ov-file#inlay-hints-textdocumentinlayhint) for more information.
|
See [typescript-language-server inlayhints documentation](https://github.com/typescript-language-server/typescript-language-server?tab=readme-ov-file#inlay-hints-textdocumentinlayhint) for more information.
|
||||||
|
|
||||||
|
When using `vtsls`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"lsp": {
|
||||||
|
"vtsls": {
|
||||||
|
"settings": {
|
||||||
|
// For JavaScript:
|
||||||
|
"javascript": {
|
||||||
|
"inlayHints": {
|
||||||
|
"parameterNames": {
|
||||||
|
"enabled": "all",
|
||||||
|
"suppressWhenArgumentMatchesName": false
|
||||||
|
},
|
||||||
|
"parameterTypes": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"variableTypes": {
|
||||||
|
"enabled": true,
|
||||||
|
"suppressWhenTypeMatchesName": true
|
||||||
|
},
|
||||||
|
"propertyDeclarationTypes": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"functionLikeReturnTypes": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"enumMemberValues": {
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// For TypeScript:
|
||||||
|
"typescript": {
|
||||||
|
"inlayHints": {
|
||||||
|
"parameterNames": {
|
||||||
|
"enabled": "all",
|
||||||
|
"suppressWhenArgumentMatchesName": false
|
||||||
|
},
|
||||||
|
"parameterTypes": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"variableTypes": {
|
||||||
|
"enabled": true,
|
||||||
|
"suppressWhenTypeMatchesName": true
|
||||||
|
},
|
||||||
|
"propertyDeclarationTypes": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"functionLikeReturnTypes": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"enumMemberValues": {
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Zed Yarn documentation](./yarn.md) for a walkthrough of configuring your project to use Yarn.
|
- [Zed Yarn documentation](./yarn.md) for a walkthrough of configuring your project to use Yarn.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue