SolidLSP Framework
Relevant source files
The following files were used as context for generating this wiki page:
The SolidLSP Framework is a powerful semantic abstraction layer within Serena that integrates and manages various Language Servers implementing the Language Server Protocol (LSP). Its primary purpose is to provide the AI agent with "IDE-like" capabilities—such as symbol discovery, cross-file reference resolution, and precise code navigation—across a vast array of programming languages.
By abstracting the complexities of individual language server implementations, SolidLSP enables a uniform interface for code retrieval and analysis. It serves as the open-source alternative to the Serena JetBrains Plugin, offering support for over 40 languages by spawning and communicating with dedicated language server processes.
Sources: README.md:104-122, src/serena/config/serena_config.py:175-180
Architecture and Language Support
SolidLSP is designed around a modular architecture where each supported language is mapped to a specific server implementation. The framework handles the lifecycle of these servers, including automatic binary downloads for certain servers (e.g., Elixir, Luau, Pascal) and managing the communication via the standard LSP protocol.
Core Components
The following diagram illustrates the relationship between the central configuration, the SolidLanguageServer abstraction, and the specific language server implementations.
The framework uses the Language enum to identify and configure the appropriate server class for a given file or project.
Sources: src/solidlsp/ls_config.py:53-241, src/solidlsp/ls_config.py:440-600
Supported Languages (Selection)
SolidLSP provides broad coverage, ranging from mainstream languages to specialized scripting and documentation formats.
| Category | Languages Supported |
|---|---|
| Mainstream | Python, Java, C#, C++, TypeScript, Go, Rust, Swift |
| Functional | Elixir, Clojure, Haskell, OCaml, Erlang, F# |
| Scripting/Web | PHP, Ruby, Dart, Lua, PowerShell, Bash, Svelte, Vue |
| Specialized | MATLAB, LaTeX, Solidity, GDScript, mSL (mIRC), BSL |
| Data/Config | JSON, YAML, TOML, Nix, Terraform |
Sources: src/solidlsp/ls_config.py:53-241, README.md:124-131
Semantic Capabilities
The framework exposes a set of standardized APIs that the Serena agent uses to perform complex coding tasks. These capabilities are exercised through the SolidLanguageServer interface.
Symbol Discovery and Navigation
The framework allows agents to explore code at the symbol level rather than reading raw text. This includes:
- Document Symbols: Retrieving an outline of a file (classes, methods, variables). For Markdown and LaTeX, these are often remapped to headings and sections.
- Go to Definition: Finding the source location of a symbol's declaration.
- Find References: Locating all usages of a specific symbol across the entire workspace.
Sources: test/solidlsp/python/test_python_basic.py:27-70, test/solidlsp/matlab/test_matlab_basic.py:57-110, test/solidlsp/latex/test_latex_references.py:38-60
Diagnostic and Analysis Flow
The framework facilitates the retrieval of diagnostics (errors, warnings) and hover information to provide context to the agent.
This flow allows the agent to identify and fix issues like undefined names or missing dependencies.
Sources: test/solidlsp/python/test_python_basic.py:84-102, src/solidlsp/language_servers/elixir_tools/README.md:65-72
Configuration and Management
SolidLSP is configured via LanguageServerConfig and global settings within SerenaConfig.
File Matching Logic
A critical part of the framework is the FilenameMatcher, which determines which language server should handle a specific file based on its extension.
# Example of extension mapping logic in ls_config.py
match self:
case self.PYTHON:
return FilenameMatcher(".py", ".pyi")
case self.ELIXIR:
return FilenameMatcher(".ex", ".exs")
case self.LATEX:
return FilenameMatcher(".tex", ".bib", ".sty", ".cls")
Sources: src/solidlsp/ls_config.py:307-438
Performance and Budgeting
To prevent the agent from hanging on large codebases, SolidLSP supports a symbol info budget. This is a time budget (in seconds) for requests. If exceeded, the framework returns partial results. The default is 10.0 seconds.
Sources: src/serena/config/serena_config.py:596-604
Implementation Example: Elixir (Expert/Next LS)
The Elixir integration demonstrates how SolidLSP handles external language server binaries. It uses "Expert" (Next LS) and manages project-specific versions via .tool-versions (asdf) automatically. It also defines specific directories to ignore (e.g., _build/, deps/) while focusing on source code in lib/ and test/.
Sources: src/solidlsp/language_servers/elixir_tools/README.md:9-40
Summary
The SolidLSP Framework is the backbone of Serena's semantic code understanding. By providing a unified interface to over 40 language servers, it enables AI agents to perform complex, cross-file operations with the same precision as a developer using a modern IDE. It manages the entire lifecycle of LSP processes, from binary acquisition and configuration to protocol-level communication and diagnostic reporting.