From 53524062d80b5e2535adfb358af6b45593927227 Mon Sep 17 00:00:00 2001 From: zen010101 <60574100+zen010101@users.noreply.github.com> Date: Sun, 18 Jan 2026 13:43:23 +0800 Subject: [PATCH 1/3] feat(pascal): Support ls_specific_settings for Pascal LSP Add support for configuring Pascal Language Server via ls_specific_settings: - pp: Path to FPC compiler driver (must be fpc.exe, not ppc386.exe) - fpcdir: Path to FPC source directory - lazarusdir: Path to Lazarus directory - fpc_target: Override target OS (FPCTARGET env var) - fpc_target_cpu: Override target CPU (FPCTARGETCPU env var) These settings are passed as environment variables to pasls, enabling CodeTools to properly configure target platform and locate source files. This fixes hover/navigation issues with complex include directives like those in mORMot2 project. --- .../language_servers/pascal_server.py | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/solidlsp/language_servers/pascal_server.py b/src/solidlsp/language_servers/pascal_server.py index bb1c9e13..2fe9ad46 100644 --- a/src/solidlsp/language_servers/pascal_server.py +++ b/src/solidlsp/language_servers/pascal_server.py @@ -12,7 +12,26 @@ Supported platforms for binary download: - win-x64 You can pass the following entries in ls_specific_settings["pascal"]: -- (reserved for future use) + +Environment variables (recommended for CodeTools configuration): +- pp: Path to FPC compiler driver, must be "fpc.exe" (e.g., "D:/laz32/fpc/bin/i386-win32/fpc.exe"). + Do NOT use backend compilers like ppc386.exe or ppcx64.exe - CodeTools queries fpc.exe for + configuration (fpc -iV, fpc -iTO, etc.). This is the most important setting for hover/navigation. +- fpcdir: Path to FPC source directory (e.g., "D:/laz32/fpcsrc"). Helps CodeTools locate + standard library sources for better navigation. +- lazarusdir: Path to Lazarus directory (e.g., "D:/laz32/lazarus"). Required for Lazarus + projects using LCL and other Lazarus components. + +Target platform overrides (use only if pp setting is not sufficient): +- fpc_target: Override target OS (e.g., "Win32", "Win64", "Linux"). Sets FPCTARGET env var. +- fpc_target_cpu: Override target CPU (e.g., "i386", "x86_64", "aarch64"). Sets FPCTARGETCPU. + +Example configuration in ~/.serena/serena_config.yml: + ls_specific_settings: + pascal: + pp: "D:/laz32/fpc/bin/i386-win32/fpc.exe" + fpcdir: "D:/laz32/fpcsrc" + lazarusdir: "D:/laz32/lazarus" """ import logging @@ -46,10 +65,51 @@ class PascalLanguageServer(SolidLanguageServer): Use LanguageServer.create() instead. """ pasls_executable_path = self._setup_runtime_dependencies(solidlsp_settings) + + # Build environment variables for pasls + # These control CodeTools' configuration and target platform settings + proc_env: dict[str, str] = {} + + # Read from ls_specific_settings["pascal"] + from solidlsp.ls_config import Language + + pascal_settings = solidlsp_settings.get_ls_specific_settings(Language.PASCAL) + + # pp: Path to FPC compiler driver (must be fpc.exe, NOT ppc386.exe/ppcx64.exe) + # CodeTools queries fpc.exe for configuration via "fpc -iV", "fpc -iTO", etc. + pp = pascal_settings.get("pp", "") + if pp: + proc_env["PP"] = pp + log.info(f"Setting PP={pp} from ls_specific_settings") + + # fpcdir: Path to FPC source directory (e.g., "D:/laz32/fpcsrc") + fpcdir = pascal_settings.get("fpcdir", "") + if fpcdir: + proc_env["FPCDIR"] = fpcdir + log.info(f"Setting FPCDIR={fpcdir} from ls_specific_settings") + + # lazarusdir: Path to Lazarus directory (e.g., "D:/laz32/lazarus") + lazarusdir = pascal_settings.get("lazarusdir", "") + if lazarusdir: + proc_env["LAZARUSDIR"] = lazarusdir + log.info(f"Setting LAZARUSDIR={lazarusdir} from ls_specific_settings") + + # fpc_target: Override target OS (e.g., "Win32", "Win64", "Linux") + fpc_target = pascal_settings.get("fpc_target", "") + if fpc_target: + proc_env["FPCTARGET"] = fpc_target + log.info(f"Setting FPCTARGET={fpc_target} from ls_specific_settings") + + # fpc_target_cpu: Override target CPU (e.g., "i386", "x86_64", "aarch64") + fpc_target_cpu = pascal_settings.get("fpc_target_cpu", "") + if fpc_target_cpu: + proc_env["FPCTARGETCPU"] = fpc_target_cpu + log.info(f"Setting FPCTARGETCPU={fpc_target_cpu} from ls_specific_settings") + super().__init__( config, repository_root_path, - ProcessLaunchInfo(cmd=pasls_executable_path, cwd=repository_root_path), + ProcessLaunchInfo(cmd=pasls_executable_path, cwd=repository_root_path, env=proc_env), "pascal", solidlsp_settings, ) From dabf14f1f6289e3a69f51a6cf2fb1679746b15cd Mon Sep 17 00:00:00 2001 From: zen010101 <60574100+zen010101@users.noreply.github.com> Date: Fri, 23 Jan 2026 16:49:07 +0800 Subject: [PATCH 2/3] docs: Add Pascal language server configuration documentation Document pasls settings including: - Language server installation (PATH vs auto-download) - Auto-update behavior (24h interval, SHA256 verification, atomic updates) - Configuration via environment variables (PP, FPCDIR, LAZARUSDIR, etc.) --- docs/02-usage/050_configuration.md | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/02-usage/050_configuration.md b/docs/02-usage/050_configuration.md index f164d567..6d0831e3 100644 --- a/docs/02-usage/050_configuration.md +++ b/docs/02-usage/050_configuration.md @@ -215,6 +215,45 @@ Notes: - `GOFLAGS` (from the environment you start Serena in) may also affect the Go build context. Prefer `buildFlags` for tags. - Build context changes are only picked up when `gopls` starts. After changing `gopls_settings` (or relevant env vars like `GOFLAGS`), restart the Serena process (or server) that hosts the Go language server, or use your client's "Restart language server" action if it causes `gopls` to restart. +#### Pascal (`pasls`) + +Serena uses [pasls](https://github.com/genericptr/pascal-language-server) (Pascal Language Server) for Pascal/Free Pascal support. + +**Language Server Installation:** + +1. If `pasls` is found in your system PATH, Serena uses it directly +2. Otherwise, Serena automatically downloads a prebuilt binary from GitHub releases + +Supported platforms for automatic download: Linux (x64, arm64), macOS (x64, arm64), Windows (x64). + +**Auto-Update:** + +Serena automatically checks for pasls updates every 24 hours. Updates include: +- SHA256 checksum verification before installation +- Atomic update with rollback on failure +- Windows file locking detection (defers update if pasls is in use) + +**Configuration via Environment Variables:** + +pasls reads compiler paths from environment variables. Set these before starting Serena: + +| Variable | Description | +| -------------- | -------------------------------------------------------- | +| `PP` | Path to FPC compiler executable | +| `FPCDIR` | Path to FPC source directory | +| `LAZARUSDIR` | Path to Lazarus directory (only needed for LCL projects) | +| `FPCTARGET` | Target OS (e.g., `linux`, `win64`, `darwin`) | +| `FPCTARGETCPU` | Target CPU (e.g., `x86_64`, `aarch64`, `i386`) | + +Example (bash): + +```bash +export PP=/usr/bin/fpc +export FPCDIR=/usr/share/fpcsrc +export LAZARUSDIR=/usr/share/lazarus +serena start-mcp-server --project /path/to/pascal-project +``` + ### Custom Prompts All of Serena's prompts can be fully customized. From ab3787c8e3058980f8d13460248137f260d77368 Mon Sep 17 00:00:00 2001 From: zen010101 <60574100+zen010101@users.noreply.github.com> Date: Sat, 24 Jan 2026 07:06:59 +0800 Subject: [PATCH 3/3] docs: Update Pascal docs to focus on ls_specific_settings Changed documentation to describe ls_specific_settings configuration instead of environment variables, as suggested by reviewer. --- docs/02-usage/050_configuration.md | 36 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/docs/02-usage/050_configuration.md b/docs/02-usage/050_configuration.md index 6d0831e3..716d541a 100644 --- a/docs/02-usage/050_configuration.md +++ b/docs/02-usage/050_configuration.md @@ -233,27 +233,33 @@ Serena automatically checks for pasls updates every 24 hours. Updates include: - Atomic update with rollback on failure - Windows file locking detection (defers update if pasls is in use) -**Configuration via Environment Variables:** +**Configuration:** -pasls reads compiler paths from environment variables. Set these before starting Serena: +Configure pasls via `ls_specific_settings.pascal` in `serena_config.yml`: -| Variable | Description | -| -------------- | -------------------------------------------------------- | -| `PP` | Path to FPC compiler executable | -| `FPCDIR` | Path to FPC source directory | -| `LAZARUSDIR` | Path to Lazarus directory (only needed for LCL projects) | -| `FPCTARGET` | Target OS (e.g., `linux`, `win64`, `darwin`) | -| `FPCTARGETCPU` | Target CPU (e.g., `x86_64`, `aarch64`, `i386`) | +| Setting | Description | +| ---------------- | --------------------------------------------------------------------------- | +| `pp` | Path to FPC compiler driver (must be `fpc` or `fpc.exe`, not `ppc386.exe`) | +| `fpcdir` | Path to FPC source directory | +| `lazarusdir` | Path to Lazarus directory (required for LCL projects) | +| `fpc_target` | Target OS override (e.g., `Win32`, `Win64`, `Linux`) | +| `fpc_target_cpu` | Target CPU override (e.g., `i386`, `x86_64`, `aarch64`) | -Example (bash): +Example configuration: -```bash -export PP=/usr/bin/fpc -export FPCDIR=/usr/share/fpcsrc -export LAZARUSDIR=/usr/share/lazarus -serena start-mcp-server --project /path/to/pascal-project +```yaml +ls_specific_settings: + pascal: + pp: "D:/laz32/fpc/bin/i386-win32/fpc.exe" + fpcdir: "D:/laz32/fpcsrc" + lazarusdir: "D:/laz32/lazarus" ``` +Notes: +- The `pp` setting is the most important for hover and navigation to work correctly. +- Use the FPC compiler driver (`fpc`/`fpc.exe`), not backend compilers like `ppc386.exe`. +- These settings are passed as environment variables to the pasls process. + ### Custom Prompts All of Serena's prompts can be fully customized.