Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. OCaml
  3. ocaml-lsp

ocaml-lsp

NOASSERTIONOCaml1.26.0

A language server implementing the Language Server Protocol (LSP) for OCaml, providing editor support like autocompletion and diagnostics.

GitHubGitHub
894 stars154 forks0 contributors

What is ocaml-lsp?

OCaml-LSP is a language server that implements the Language Server Protocol (LSP) for the OCaml programming language. It provides IDE-like features such as autocompletion, hover documentation, go-to-definition, and code formatting directly within code editors that support LSP. It solves the problem of fragmented editor support for OCaml by offering a standardized, feature-rich tooling interface.

Target Audience

OCaml developers using editors like VS Code, Emacs, or Vim who want enhanced productivity features such as intelligent code assistance, real-time diagnostics, and refactoring tools.

Value Proposition

Developers choose OCaml-LSP because it is the official, most comprehensive LSP implementation for OCaml, offering deep integration with the OCaml ecosystem (like Dune and Merlin), unique OCaml-specific features (e.g., destruct/construct code actions), and strong community support.

Overview

OCaml Language Server Protocol implementation

Use Cases

Best For

  • Adding intelligent autocompletion and documentation hover to OCaml projects
  • Integrating OCaml support into LSP-compatible code editors
  • Refactoring OCaml code with go-to-definition and find references
  • Using advanced code actions like generating pattern matches or constructing values by type
  • Formatting OCaml source code automatically within the editor
  • Debugging OCaml programs with real-time build diagnostics via Dune integration

Not Ideal For

  • Projects using build systems other than Dune without Merlin integration
  • Editors without LSP client support or plugins for OCaml-specific extensions
  • Teams unwilling to run Dune in watch mode for real-time diagnostics
  • Developers requiring full LSP standard compliance, including unsupported features like document coloring

Pros & Cons

Pros

Deep OCaml Toolchain Integration

Integrates with Dune's RPC for build diagnostics and file promotion, and leverages Merlin for accurate code analysis, as stated in the README's sections on Dune integration and relationship to Merlin.

Advanced Code Actions

Offers unique features like 'Destruct' for generating exhaustive pattern matches and 'Construct' for building expressions based on type, detailed in the 'Unusual features' section.

Semantic Highlighting Support

Provides experimental semantic token support for richer syntax coloring, configurable via environment variables like OCAMLLSP_SEMANTIC_HIGHLIGHTING, as explained in the semantic highlighting section.

Typed Holes for Development

Allows using underscores as typed placeholders during development, enabling incremental coding with well-typed substitutes, described in the typed holes subsection.

Cons

Incomplete LSP Standard Support

Does not implement some LSP requests such as 'textDocument/implementation' and 'textDocument/documentColor', limiting compatibility with editors expecting full protocol adherence.

Complex Multi-Switch Setup

Requires installation in every opam switch where it's used, and additional packages like ocamlformat for formatting support, adding to setup overhead as noted in the installation section.

Dependency on External Build Process

Relies on Dune running in watch mode for accurate diagnostics and features like file promotion, which may not suit all workflows and can introduce latency, as mentioned in the Dune integration caveats.

Frequently Asked Questions

Quick Stats

Stars894
Forks154
Contributors0
Open Issues140
Last commit10 hours ago
CreatedSince 2019

Tags

#developer-tools#language-server#editor-tooling#lsp#static-analysis#code-completion#ocaml

Built With

d
dune
O
OCaml

Included in

OCaml3.1k
Auto-fetched 7 hours ago

Related Projects

merlinmerlin

Context sensitive completion for OCaml in Vim and Emacs

Stars1,679
Forks251
Last commit2 days ago
utoputop

Universal toplevel for OCaml

Stars918
Forks121
Last commit1 month ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub