History

Slightly improve completion in settings.json (for lsp.<language-server>.) (#42263)

Document "any-typed" (`serde_json::Value`) "lsp" keys to include them in json-language-server completions. The vscode-json-languageserver seems to skip generically typed keys when offering completion. For this schema ``` "LspSettings": { "type": "object", "properties": { ... "initialization_options": true, ... } } ``` "initialization_options" is not offered in the completion. The effect is easy to verify by triggering completion inside: ``` "lsp": { "basedpyright": { COMPLETE HERE ``` <img width="797" height="215" alt="image" src="https://github.com/user-attachments/assets/d1d1391c-d02c-4028-9888-8869f4d18b0f" /> By adding a documentation string the keys are offered even if they are generically typed: <img width="809" height="238" alt="image" src="https://github.com/user-attachments/assets/9a072da9-961b-4e15-9aec-3d56933cbe67" /> --- Note: I did some cursory research of whether it's possible to make vscode-json-languageserver change behavior without success. IMO, not offering completions here is a bug (or at minimal should be configurable) --- Release Notes: - N/A ---------

Ole Jørgen Brønner committed 1 year ago

Commit efcd7f71 parent aaf2f9d1 file · +13 −0Browse files

Unified · Split

crates/settings/src/settings_content/project.rs+13−0
@@ -26,6 +26,7 @@ pub struct ProjectSettingsContent { · 25 unmodified lines
2626 /// The following settings can be overridden for specific language servers:
2727 /// - initialization_options
2828 ///
29+ ///
2930 /// To override settings for a language, add an entry for that language server's
3031 /// name to the lsp value.
3132 /// Default: null
@@ -108,7 +109,19 @@ pub struct WorktreeSettingsContent { · 76 unmodified lines
108109 #[serde(rename_all = "snake_case")]
109110 pub struct LspSettings {
110111 pub binary: Option<BinarySettings>,
112+ /// Options passed to the language server at startup.
113+ ///
114+ /// Ref: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#initialize
115+ ///
116+ /// Consult the documentation for the specific language server to see what settings
117+ /// are supported.
111118 pub initialization_options: Option<serde_json::Value>,
119+ /// Language server settings.
120+ ///
121+ /// Ref: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration
122+ ///
123+ /// Consult the documentation for the specific LSP to see what settings
124+ /// are supported.
112125 pub settings: Option<serde_json::Value>,
113126 /// If the server supports sending tasks over LSP extensions,
114127 /// this setting can be used to enable or disable them in Zed.