Allow to overrride entries of initializationOptions via LS-specific settings

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-07-03 12:49:56 +02:00
1 parent f00d3cfa19
commit 352b3d3fed
3 files changed
+50

No files matched your search

+30
View File
@@ -250,6 +250,36 @@ Common examples include: `ansible`, `bash`, `bsl`, `clojure`, `cpp`, `cpp_ccls`,
If `ls_path` is set, Serena's managed download or install is bypassed for that language server.
In that case, any server-specific version or registry settings do not apply.
(override-init-options)=
#### Overriding Language Server Initialization Options
When Serena starts a language server, it sends a set of `initializationOptions` as part of the
Language Server Protocol `initialize` request. These options are constructed internally and are
tailored to each language server. In some cases, you may want to override or extend these options,
e.g. to enable a feature or to adjust a behavior that is specific to your setup.
Under the key `initializationOptions` within a language's `ls_specific_settings`, you can provide a
dictionary of options that is applied on top of the internally constructed `initializationOptions`.
The values are combined at the top level only: for each top-level key you define, your value
replaces the original value for that key exactly as given (there is no recursive/deep merge of
nested dictionaries). Internally constructed keys that you do not define are left unchanged.
* If Serena constructs `initializationOptions` for the language server, each top-level key you
provide replaces the internally constructed value for that same key, while all other internally
constructed keys are retained.
* If Serena does not construct any `initializationOptions` for the language server, your custom
options are used as-is.
Example:
```yaml
ls_specific_settings:
<language>:
initializationOptions:
someFeature:
enabled: true
```
#### AL
Serena uses the AL language server bundled in the Microsoft Dynamics 365 Business Central VS Code extension.
+13
View File
@@ -67,3 +67,16 @@ class DefaultInitializeParamsBuilder(InitializeParamsBuilder):
log.info("Additional workspace folders (not indexed by SolidLSP): %s", additional_abs_workspace_paths)
workspace_folders.extend([self._create_workspace_folder_entry(abs_path) for abs_path in additional_abs_workspace_paths])
self._set("workspaceFolders", workspace_folders)
init_options_key = "initializationOptions"
custom_init_options = self._ls.custom_settings.get(init_options_key, None)
if custom_init_options:
if not isinstance(custom_init_options, dict):
log.error("Custom initialization options should be a dictionary, but got %s. Ignoring.", type(custom_init_options).__name__)
else:
log.info("Applying custom initialization options: %s", custom_init_options)
if init_options_key in self._params:
self._params[init_options_key].update(custom_init_options)
else:
self._params[init_options_key] = custom_init_options
log.info("Final initialization options: %s", self._params[init_options_key])
+7
View File
@@ -764,6 +764,13 @@ class SolidLanguageServer(ABC):
"""
self._abs_workspace_folders_all = self._abs_workspace_folders_indexed + self._abs_workspace_folders_additional
@property
def custom_settings(self) -> SolidLSPSettings.CustomLSSettings:
"""
The (user-provided) language server-specific settings.
"""
return self._custom_settings
def _create_dependency_provider(self) -> LanguageServerDependencyProvider:
"""
Creates the dependency provider for this language server.