Merge pull request #950 from zen010101/feature/pascal-ls-specific-settings

feat(pascal): Support ls_specific_settings for Pascal LSP
This commit is contained in:
Dominik Jain authored and GitHub committed 2026-01-24 02:14:45 +01:00
commit 62e407dae5
2 files changed
+107 -2

No files matched your search

+45
View File
@@ -215,6 +215,51 @@ 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:**
Configure pasls via `ls_specific_settings.pascal` in `serena_config.yml`:
| 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 configuration:
```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.
+62 -2
View File
@@ -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,
)