From 60abdd5297be9d1b499a80bd0ebf5a3b2d8e1374 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Thu, 2 Jul 2026 15:29:00 +0200 Subject: [PATCH] Support ls_args and ls_extra_args centrally in LanguageServerDependencyProviderBaseCommand * ls_args overrides the internal command builder, fully defining the arguments * ls_extra_args appends additional arguments to the launch command --- CHANGELOG.md | 1 + docs/02-usage/050_configuration.md | 36 ++++++++++++++++++------------ src/solidlsp/ls.py | 33 ++++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 387e9146..c616bbea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ Status of the `main` branch. Changes prior to the next official version change w - Improve quoting of arguments in shell executions - Add **LaTeX** support (experimental) via [texlab](https://github.com/latex-lsp/texlab). - PHP: add support for PHPantom as alternative to the already supported PHP LS #1554. + - Add new launch command customization options: `ls_args`, `ls_extra_args` * JetBrains: - Add configuration option `jetbrains_launch_command`, allowing Serena to spawn IDE instances automatically diff --git a/docs/02-usage/050_configuration.md b/docs/02-usage/050_configuration.md index 8aa12542..ee00ea57 100644 --- a/docs/02-usage/050_configuration.md +++ b/docs/02-usage/050_configuration.md @@ -216,31 +216,39 @@ ls_specific_settings: ``` (override-ls-path)= -#### Overriding the Language Server Path +#### Customizing the Language Server Launch Command -Most of Serena's language servers, particularly those that use a single core path for the language server (e.g. the main executable), -support overriding that path via the `ls_path` setting. -Therefore, if you have installed the language server yourself and want to use your installation -instead of Serena's managed installation, you can set the `ls_path` setting as follows: +Most of Serena's language servers construct the command that launches the language server process from +a *base command* or a *core dependency*. +For these language servers, the following settings can be used to customize the launch command: + +| Setting | Description | +|------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `ls_path` (string) | overrides the path of the language server's core dependency (e.g. its executable or a JAR file). Use this if you have installed the language server yourself and want Serena to use your installation instead of its managed installation. | +| `ls_args` (list) | overrides the internal command construction completely and simply adds `ls_args` to the base command | +| `ls_extra_args` (list) | a list of additional arguments to append to the launch command | + +* If you set `ls_args`, the internal command construction (which may do more than to append arguments to a base command) is bypassed. + You can define the full launch command by providing both `ls_path` and `ls_args`. +* If `ls_args` is not set, the internal command construction (which sets default arguments) is applied, and you can use `ls_path` to override the path of the core dependency. +* `ls_extra_args` is always appended to the end of the launch command. + +Example: ```yaml ls_specific_settings: : ls_path: "/path/to/language-server" + ls_extra_args: ["--log-level=debug"] ``` -This is supported by all language servers deriving their dependency provider from `LanguageServerDependencyProviderSinglePath`, -and by some additional wrappers that explicitly expose `ls_path`. +These settings are supported by all language servers whose dependency provider derives from +`LanguageServerDependencyProviderBaseCommand`, and `ls_path` is additionally exposed by some wrappers explicitly. Common examples include: `ansible`, `bash`, `bsl`, `clojure`, `cpp`, `cpp_ccls`, `hlsl`, `html`, `kotlin`, `lean4`, `luau`, `markdown`, `php`, `php_phpactor`, `python`, `rust`, `scss`, `solidity`, `systemverilog`, `toml`, `typescript`, and `yaml`. -Note: `angular` does **not** support `ls_path` — the Angular language server is part of a multi-process orchestration -(`ngserver` plus a companion TypeScript language server with the `@angular/language-service` plugin and an HTML -companion) where the dependency layout matters; use the version overrides documented in the Angular section below -to pin specific releases of the bundled stack. - -If a language server supports `ls_path`, setting it bypasses Serena's managed download or install for that server. -In that case, any server-specific version or registry settings only apply when `ls_path` is not set. +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. #### AL diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index 1147e1a7..7b116419 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -301,8 +301,14 @@ class LanguageServerDependencyProvider(ABC): class LanguageServerDependencyProviderBaseCommand(LanguageServerDependencyProvider, ABC): """ - Special case of a dependency provider, where the launch command is constructed from a base command - (which can potentially be overridden by the user in LS-specific settings). + Special case of a dependency provider, where the launch command is constructed from a base command. + + The user can configure aspects of the launch command in LS-specific settings: + + * ``ls_path``: overrides the path of the language server's core dependency (e.g. its executable or a JAR file), + from which the base command is formed, bypassing Serena's managed installation + * ``ls_args``: overrides the arguments that are added to the base command in order to form the launch command + * ``ls_extra_args``: additional arguments to append to the launch command """ @abstractmethod @@ -326,12 +332,33 @@ class LanguageServerDependencyProviderBaseCommand(LanguageServerDependencyProvid """ def create_launch_command(self) -> list[str]: + # obtain base command ls_path = self._custom_settings.get("ls_path", None) if ls_path is not None: base_command = [ls_path] else: base_command = self._create_default_base_command() - return self._create_launch_command_from_base_command(list(base_command)) + + # create launch command from base command + ls_args = self._custom_settings.get("ls_args") + if ls_args is not None: + if not isinstance(ls_args, list): + log.warning("The 'ls_args' setting should be a list of strings. Ignoring the provided value: %s", ls_args) + ls_args = None + if ls_args is not None: + cmd = list(base_command) + ls_args + else: + cmd = self._create_launch_command_from_base_command(list(base_command)) + + # add user-provided extra arguments (if any) + ls_extra_args = self._custom_settings.get("ls_extra_args", []) + if ls_extra_args: + if not isinstance(ls_extra_args, list): + log.warning("The 'ls_extra_args' setting should be a list of strings. Ignoring the provided value: %s", ls_extra_args) + else: + cmd = cmd + ls_extra_args + + return cmd class LanguageServerDependencyProviderSinglePath(LanguageServerDependencyProviderBaseCommand, ABC):