Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add default language server settings to display inlay hints for Go and TypeScript (#7854)
Kirill Bulatovbdc2558eac9f
diff --git a/crates/zed/src/languages/go.rs b/crates/zed/src/languages/go.rsindex cb171d5bd30..83adf45d4b2 100644--- a/crates/zed/src/languages/go.rs+++ b/crates/zed/src/languages/go.rs@@ -174,6 +174,15 @@ impl super::LspAdapter for GoLspAdapter {fn initialization_options(&self) -> Option<serde_json::Value> {Some(json!({"usePlaceholders": true,+ "hints": {+ "assignVariableTypes": true,+ "compositeLiteralFields": true,+ "compositeLiteralTypes": true,+ "constantValues": true,+ "functionTypeParameters": true,+ "parameterNames": true,+ "rangeVariableTypes": true+ }}))}diff --git a/crates/zed/src/languages/typescript.rs b/crates/zed/src/languages/typescript.rsindex 6ee8e34bfd3..34640d0ed39 100644--- a/crates/zed/src/languages/typescript.rs+++ b/crates/zed/src/languages/typescript.rs@@ -160,6 +160,16 @@ impl LspAdapter for TypeScriptLspAdapter {"tsserver": {"path": "node_modules/typescript/lib",},+ "preferences": {+ "includeInlayParameterNameHints": "all",+ "includeInlayParameterNameHintsWhenArgumentMatchesName": true,+ "includeInlayFunctionParameterTypeHints": true,+ "includeInlayVariableTypeHints": true,+ "includeInlayVariableTypeHintsWhenTypeMatchesName": true,+ "includeInlayPropertyDeclarationTypeHints": true,+ "includeInlayFunctionLikeReturnTypeHints": true,+ "includeInlayEnumMemberValueHints": true,+ }}))}diff --git a/docs/src/languages/go.md b/docs/src/languages/go.mdindex 29924aa7463..79ab5610fb5 100644--- a/docs/src/languages/go.md+++ b/docs/src/languages/go.md@@ -3,6 +3,40 @@- Tree Sitter: [tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go)- Language Server: [gopls](https://github.com/golang/tools/tree/master/gopls)+## Inlay Hints++Zed sets the following initialization options for inlay hints:++```json+"hints": {+ "assignVariableTypes": true,+ "compositeLiteralFields": true,+ "compositeLiteralTypes": true,+ "constantValues": true,+ "functionTypeParameters": true,+ "parameterNames": true,+ "rangeVariableTypes": true+}+```++to make the language server send back inlay hints when Zed has them enabled in the settings.++Use+```json+"lsp": {+ "$LANGUAGE_SERVER_NAME": {+ "initialization_options": {+ "hints": {+ ....+ }+ }+ }+}+```+to override these settings.++See https://github.com/golang/tools/blob/master/gopls/doc/inlayHints.md for more information.+# Go Mod- Tree Sitter: [tree-sitter-gomod](https://github.com/camdencheek/tree-sitter-go-mod)diff --git a/docs/src/languages/typescript.md b/docs/src/languages/typescript.mdindex 91b72115feb..4bfd15dc160 100644--- a/docs/src/languages/typescript.md+++ b/docs/src/languages/typescript.md@@ -2,3 +2,38 @@- Tree Sitter: [tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript)- Language Server: [typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)++## Inlay Hints++Zed sets the following initialization options for inlay hints:++```json+"preferences": {+ "includeInlayParameterNameHints": "all",+ "includeInlayParameterNameHintsWhenArgumentMatchesName": true,+ "includeInlayFunctionParameterTypeHints": true,+ "includeInlayVariableTypeHints": true,+ "includeInlayVariableTypeHintsWhenTypeMatchesName": true,+ "includeInlayPropertyDeclarationTypeHints": true,+ "includeInlayFunctionLikeReturnTypeHints": true,+ "includeInlayEnumMemberValueHints": true,+}+```++to make the language server send back inlay hints when Zed has them enabled in the settings.++Use+```json+"lsp": {+ "$LANGUAGE_SERVER_NAME": {+ "initialization_options": {+ "preferences": {+ ....+ }+ }+ }+}+```+to override these settings.++See https://github.com/typescript-language-server/typescript-language-server?tab=readme-ov-file#inlay-hints-textdocumentinlayhint for more information.