feat: Add comprehensive OCaml language support with ocaml-lsp-server integration
This PR adds full OCaml language support to Serena through integration with the ocaml-lsp-server, following the established solidlsp architecture pattern.
Changes Made:
Core Language Server Integration
- New OCamlLspServer class (
src/solidlsp/language_servers/ocaml_lsp_server/ocaml_lsp_server.py):- Implements solidlsp interface for ocaml-lsp-server
- Handles OCaml-specific initialization parameters and capabilities
- Manages Dune build system integration and workspace detection
- Includes proper error handling and logging
Runtime Dependencies Management
- Automatic dependency resolution for ocaml-lsp-server installation
- Runtime dependencies configuration specifying required OCaml toolchain versions
- Cross-platform support for different OCaml installation methods
Language Support Registration
- Added
OCamlto the Language enum inls_config.py - Integrated OCaml support into the language server factory in
ls.py - Added
ocamlpytest marker topyproject.tomlfor targeted testing
Comprehensive Test Infrastructure
-
Realistic test repository (
test/resources/repos/ocaml/test_repo/):- Complete Dune project structure with
dune-project,.opamfiles - Library module with interface file (
.mli) demonstrating OCaml conventions - Executable binary and test suite following OCaml best practices
- Proper module dependencies and build configuration
- Complete Dune project structure with
-
Test suite (
test/solidlsp/ocaml/test_ocaml_basic.py):- Symbol discovery and navigation tests
- Reference finding across modules and interfaces
- Integration testing with Dune build system
- Validation of LSP capabilities specific to OCaml
Build System Integration
- Dune project support with proper workspace detection
- OPAM package management integration for dependency resolution
- Interface file (.mli) handling for OCaml's module system
Technical Implementation Details:
- Follows established solidlsp patterns for consistency with existing language servers
- Implements OCaml-specific LSP initialization parameters for optimal language server performance
- Handles OCaml's unique module system with proper interface file support
- Integrates with Dune's workspace model for accurate project boundary detection
Testing Strategy:
- Language-specific test suite using
ocamlpytest marker - Realistic OCaml project structure for integration testing
- Validation of core LSP operations (symbols, references, definitions)
- Build system integration testing with Dune
This addition brings Serena's OCaml support to the same level as other supported languages, enabling full semantic code analysis and manipulation for OCaml codebases.
Thx! Pls run poe format such that CI can run trough
@MischaPanch out of draft now
@johnhaley81 still interested in getting this merged? :)
Yes! Sorry I got sucked down a rabbit hole trying to figure out some things with cross file references with ocaml-lap-server. I'll have some more commits this weekend for it
Cool, happy to hear that!
@johnhaley81 ping :)