feat: Support project-level ls_specific_settings (#1192)

This commit is contained in:
code4lala authored and GitHub committed 2026-03-23 18:03:57 +01:00
1 parent d39d168523
commit bf92f3cb49
5 files changed
+19 -6

No files matched your search

+5 -2
View File
@@ -213,8 +213,10 @@ This ensures backward compatibility: existing projects that already have a `.ser
Most users will not need to adjust these settings.
:::
Under the key `ls_specific_settings` in `serena_config.yml`, you can you pass per-language,
language server-specific configuration.
Under the key `ls_specific_settings` in `serena_config.yml`, you can you pass global per-language,
language server-specific configuration. You can use the same key in the project configuration files (`project.yml`
and `project.local.yml` ) to override or extend the global settings for a specific project.
The settings are merged on top-level, meaning that project-level settings for a language will replace global settings for the same language.
Structure:
@@ -230,6 +232,7 @@ Most settings are currently undocumented. Please refer to the
implementation to determine supported settings.
:::
(override-ls-path)=
#### Overriding the Language Server Path
Some language servers, particularly those that use a single core path for the language server (e.g. the main executable),
+3 -1
View File
@@ -15,6 +15,8 @@ for cross-file reference finding, see below for details.
Your project must have a `compile_commands.json` file at the repository root.
This file is essential for correct parsing and cross-file reference finding.
You can use a specific clangd or ccls installation (e.g., a custom build or a version provided by your project),
by specifying the path in your configuration, see [ls-specific-settings](ls-specific-settings) for details.
## compile_commands.json Requirements
@@ -27,7 +29,7 @@ For reliable cross-file reference finding with clangd, your `compile_commands.js
### With clangd
Serena automatically downloads and manages clangd. Since clangd does not properly work with relative paths in `compile_commands.json`,
By default, Serena automatically downloads and manages clangd. Since clangd does not properly work with relative paths in `compile_commands.json`,
Serena will detect them and transform them into absolute paths automatically (writing a new `compile_commands.json` file), if needed.
#### Customizing the Compilation Database Location
+3 -2
View File
@@ -222,6 +222,8 @@ class SharedConfig(ModeSelectionDefinition, ToolInclusionDefinition, ToStringMix
language_backend: LanguageBackend | None = None
line_ending: LineEnding | None = None
read_only_memory_patterns: list[str] = field(default_factory=list)
ls_specific_settings: dict = field(default_factory=dict)
"""Advanced configuration option allowing to configure language server implementation specific options, see SolidLSPSettings for more info."""
class SerenaConfigError(Exception):
@@ -459,6 +461,7 @@ class ProjectConfig(SharedConfig):
base_modes=data["base_modes"],
default_modes=data["default_modes"],
symbol_info_budget=symbol_info_budget,
ls_specific_settings=data.get("ls_specific_settings", {}),
_local_override_keys=local_override_keys,
)
@@ -678,8 +681,6 @@ class SerenaConfig(SharedConfig):
Even though the value of the max_answer_chars can be changed when calling the tool, it may make sense to adjust this default
through the global configuration.
"""
ls_specific_settings: dict = field(default_factory=dict)
"""Advanced configuration option allowing to configure language server implementation specific options, see SolidLSPSettings for more info."""
ignored_paths: list[str] = field(default_factory=list)
"""List of paths to ignore across all projects. Same syntax as gitignore, so you can use * and **.
+2 -1
View File
@@ -624,13 +624,14 @@ class Project(ToStringMixin):
log.info(f"Creating language server manager for {self.project_root}")
self._language_server_manager_init_error = None
ls_specific_settings = {**self.serena_config.ls_specific_settings, **self.project_config.ls_specific_settings}
factory = LanguageServerFactory(
project_root=self.project_root,
project_data_path=self._serena_data_folder,
encoding=self.project_config.encoding,
ignored_patterns=self._ignored_patterns,
ls_timeout=ls_timeout,
ls_specific_settings=self.serena_config.ls_specific_settings,
ls_specific_settings=ls_specific_settings,
trace_lsp_communication=self.serena_config.trace_lsp_communication,
)
self.language_server_manager = LanguageServerManager.from_languages(self.project_config.languages, factory)
@@ -46,6 +46,12 @@ language_backend:
# whether to use project's .gitignore files to ignore files
ignore_all_files_in_gitignore: true
# advanced configuration option allowing to configure language server-specific options.
# Maps the language key to the options.
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
# No documentation on options means no options are available.
ls_specific_settings: {}
# list of additional paths to ignore in this project.
# Same syntax as gitignore, so you can use * and **.
# Note: global ignored_paths from serena_config.yml are also applied additively.