OCaml Changelog

RSS

Official stable release announcements and updates from the OCaml compiler, OCaml infrastructure and the OCaml Platform Tools.

CHANGES:

Features

  • Offer parenthesized application snippets for constructors with payloads, with
    independent argument slots, while retaining name-only completions. (#2212, @rgrinberg)
  • Make generated destruct branch bodies interactive for clients with snippet edit
    support. (#2204, @rgrinberg)
  • Offer whole-call completions for OCaml functions with multiple labelled or
    optional arguments, with editable slots for all arguments. (#2199, @rgrinberg)
  • Make generated construct completions interactive for clients with snippet support.
    (#2198, @rgrinberg)
  • Support ocp-indent as an alternative for document and range formatting.
    (#2148, @rgrinberg)
  • Support textDocument/onTypeFormatting through the optional, persistent
    ocp-indent-rpc helper. (#1986, @rgrinberg)
  • Report Dune RPC, build progress, and Merlin configuration process activity
    through LSP trace notifications. (#1899, @rgrinberg)
  • Add a code action to open the closest Dune file for the current document.
    (#1817, fixes #1491, @rgrinberg)
  • Distinguish operators from functions in semantic highlighting. (#1831, @rgrinberg)
  • Support textDocument/implementation for type declarations in interface files,
    including nested modules, functor results, includes, and aliases.
    (#2074, fixes #1163, @rgrinberg)
  • Classify function parameters and labels in semantic highlighting.
    (#1857, @rgrinberg)
  • Distinguish built-in from user-defined types in semantic highlighting.
    (#1858, fixes #1139, @rgrinberg)
  • Topiary formatter added (#2226, toastal)
  • Add custom
    ocamllsp/completePrefixAtPos
    request, which completes a given prefix at a given position and returns
    function argument labels separately from the completions.
    This will be used by Emacs via the
    ocaml-eglot package. (#2230, @spwhitton)

Fixes

  • Avoid overlapping semantic tokens in with type constraints and destructive
    substitutions. (#2206, @rgrinberg)
  • Preserve nested or-patterns when formatting destruct-line case-analysis
    replies. (#2194, @rgrinberg)
  • Clear stale Dune diagnostics and promotion actions when an RPC instance exits,
    without removing a replacement instance for the same root. (#2189, @rgrinberg)
  • Ensure recovered selection ranges contain the requested position. (#2170,
    @rgrinberg)
  • Suppress function extraction when a constructor would move out of scope or
    resolve to a shadowing declaration. (#2169, @rgrinberg)
  • Clamp recovered selection ranges to the document bounds. (#2061, @rgrinberg)
  • Exclude symbol declarations from reference results when requested by the
    client. (#2164, @rgrinberg)
  • Convert related locations parsed from Merlin diagnostic messages to zero-based
    LSP line numbers. (#2163, fixes #2145, @rgrinberg)
  • Preserve trailing newlines when computing post-edit ranges. (#2159,
    @rgrinberg)
  • Return only inlay hints within the range requested by the client. (#2155,
    @rgrinberg)
  • Return document symbol kinds the client supports, falling back to
    Constructor and Class when it does not advertise the newer kinds.
    (#2122, fixes #2121, @dayangac)
  • Offer the unused-code quick fixes again: they matched diagnostic messages the
    server does not emit, and marking an unused open! produced open!!.
    (#2117, fixes #2116, @dayangac)
  • Offer to create a missing implementation or interface counterpart only when
    the client supports the create resource operation. (#2115, fixes #2114,
    @dayangac)
  • Tag unused and deprecated values in diagnostics, so clients can grey them out
    or strike them through. (#2110, fixes #2109, @dayangac)
  • Honor client support for deprecation tags in workspace-symbol results.
    (#2113, @rgrinberg)
  • Respect the client's folding range capabilities: omit character positions for
    lineFoldingOnly clients, omit unsupported folding range kinds, and honor
    rangeLimit. (#2099, fixes #911, @dayangac)
  • Classify module names in with constraints and in signature opens in
    semantic highlighting. (#2098, fixes #808, @dayangac)
  • Report a type when hovering a variant constructor or an exception where it is
    declared. (#2102, fixes #1300, @dayangac)
  • Return no location instead of failing the request when a definition,
    declaration or type definition cannot be found, so clients that request them
    eagerly no longer surface spurious errors. (#2100, fixes #1161, @dayangac)
  • Prefer a same-document related location when a Dune diagnostic has an empty
    primary range, such as ml/mli mismatches. (#2093, @rgrinberg)
  • Stop offering the inferred-interface code action when the interface already
    declares everything the implementation exports. (#2096, fixes #347, @dayangac)
  • Unregister Dune promotion code actions when an RPC instance finishes.
    (#2076, @rgrinberg)
  • Avoid unregistering promotion code actions when clearing the last promotion
    for an already open document. (#2075, @rgrinberg)
  • Find destruct-line cases after module-type constraints in match scrutinees.
    (#2072, @rgrinberg)
  • Keep Dune RPC registry polling responsive while connected instances are
    running. (#1919, @rgrinberg)
  • Fix the build on FreeBSD, where statfs(2) is declared in <sys/mount.h>
    rather than <sys/statfs.h>. (#2070, fixes #1069, @dayangac)
  • Deduplicate identical rename text edits returned by Merlin recovery.
    (#2064, @rgrinberg)
  • Reject cross-line destruct recovery locations before applying line-local
    source offsets. (#2063, @rgrinberg)
  • Use consistent document snapshots and versions when converting rename
    occurrences into workspace edits. (#2062, @rgrinberg)
  • Reject malformed destruct-line recovery replies and find match separators
    lexically instead of treating identifier substrings as with. (#2043, @rgrinberg)
  • Skip inline edit construction for bindings without applicable uses, avoiding
    stack exhaustion when printing deeply recovered expressions. (#2041, @rgrinberg)
  • Keep construct-completion text edits on the request line when Merlin recovery
    returns a multiline location. (#2034, @rgrinberg)
  • Advertise Dune promotion code actions using their returned quickfix kind.
    (#2055, @rgrinberg)
  • Reject interface documents passed to the ocamllsp/inferIntf custom request
    with InvalidParams. (#2051, @rgrinberg)
  • Report malformed type-enclosing custom-request parameters as InvalidParams
    instead of an internal error. (#2050, @rgrinberg)
  • Return null from the refactor-extract custom request for empty ranges.
    (#2049, @rgrinberg)
  • Return null from the destruct custom request for inapplicable ranges.
    (#2048, @rgrinberg)
  • Return null from the construct custom request when the cursor is not at a
    typed hole. (#2047, @rgrinberg)
  • Preserve deprecation status in workspace-symbol results. (#2044, @rgrinberg)
  • Render empty odoc tables in hover documentation without raising an internal
    error. (#2038, @rgrinberg)
  • Enable function parameter inlay hints when the client sends no configuration.
    (#2097, fixes #1371, @dayangac)
  • Respect client support for signature-help parameter-label offsets. (#2009,
    @rgrinberg)
  • Keep Merlin diagnostic ranges within document bounds. (#2008, @rgrinberg)
  • Suppress triggered completion and signature help inside comments after Unicode.
    (#1994, @rgrinberg)
  • Emit semantic tokens in source order so their relative positions remain valid.
    (#1992, @rgrinberg)
  • Stop stale signature help at expression boundaries. (#1987, fixes #1162,
    @rgrinberg)
  • Suppress signature help for completed applications. (#1982, #1162, @rgrinberg)
  • Encode remove-unused code-action edits using the client's negotiated position
    encoding. (#1969, @rgrinberg)
  • Exclude surrounding parentheses from infix operator rename placeholders and
    edits. (#1966, fixes #1190, @rgrinberg)
  • Suppress signature help for applications after the cursor. (#1965, #1162,
    @rgrinberg)
  • Use each document's current version in multi-file rename edits. (#1958, @rgrinberg)
  • Handle zero-work Dune build progress updates. (#1896, @rgrinberg)
  • Do not report Dune build progress when the client disables work-done progress.
    (#2082, @rgrinberg)
  • Reject malformed Dune promotion commands. (#2084, @rgrinberg)
  • Keep Dune promotion registrations balanced when diagnostics share a source.
    (#2089, @rgrinberg)
  • Reject negative JSON-RPC Content-Length headers. (#1873, @rgrinberg)
  • Report unsupported LSP request methods as unavailable instead of internal
    server errors. (#1862, @rgrinberg)
  • Advertise semantic-token support only to clients that declare the capability.
    (#1851, @rgrinberg)
  • Advertise semantic-token support only to clients that support the relative
    token format. (#1853, @rgrinberg)
  • Advertise semantic-token support only to clients that support full-document
    requests. (#1856, @rgrinberg)
  • Advertise semantic-token delta support only to clients that request it.
    (#1859, @rgrinberg)
  • Advertise and encode only semantic token types supported by the client.
    (#1860, @rgrinberg)
  • Advertise and encode only semantic token modifiers supported by the client.
    (#1978, @rgrinberg)
  • Offer the destruct-line code action on inline match expressions with
    incomplete cases. (#1829, fixes #1595, @rgrinberg)
  • Replace a lone polymorphic-variant backtick when applying completions.
    (#1823, fixes #1427, @rgrinberg)
  • Report a missing project build-system executable as a diagnostic without
    discarding the opened document. (#1814, @rgrinberg)
  • Advertise all code-action kinds that the server may return. (#1803, @rgrinberg)
  • Respect hierarchical code-action kind filters from clients. (#1802, @rgrinberg)
  • Ensure textDocument/documentSymbol returns a selectionRange contained
    within its range, so clients no longer reject the document outline.
    (#1775, fixes #1560, @Leonard013)
  • Recompute Merlin diagnostics when diagnostic shortening changes. (#1804, @rgrinberg)
  • Avoid eagerly computing inline code-action edits when clients support lazy
    resolution. (#1808, @rgrinberg)
  • Keep URI query parameters separate from filesystem paths. (#1776, @rgrinberg)
  • Preserve URI paths beginning with two slashes across serialization. (#1798, @rgrinberg)
  • Preserve percent-encoded URI fragments across parsing and serialization. (#1801, @rgrinberg)
  • Preserve URI paths whose first segment resembles a non-letter Windows drive. (#1800, @rgrinberg)
  • Preserve unescaped Unicode in URI query components. (#1799, @rgrinberg)
  • Preserve document offsets across incremental text edits. (#1777, @rgrinberg)
  • Respect the client's preferred completion documentation format. (#1885, @rgrinberg)
  • Parse non-ASCII completion prefixes and whitespace in CRLF input. (#1886, @rgrinberg)
  • Use constructor completion kinds when clients do not support enum members. (#1887, @rgrinberg)
  • Use completion deprecation tags when supported by the client. (#1903, @rgrinberg)
  • Keep completion sort keys lexically ordered beyond 9,999 items. (#1883, @rgrinberg)
  • Replace incorrect identifier suffixes when applying completions. (#1964, fixes #838, @rgrinberg)
  • Give synthetic completion items stable ordering metadata. (#1882, @rgrinberg)
  • Preserve dotted operators in completion prefixes and resolve requests. (#1890, @rgrinberg)
  • Correct code-action ranges after multiline text insertions. (#1748, @rgrinberg)
  • Allow clients to add their first workspace folder dynamically. (#1747, @rgrinberg)
  • Unregister Dune promotion commands after their diagnostics are cleared. (#1746, @rgrinberg)
  • Point workspace symbols for generated sources to their files in the build
    directory. (#1742, @tatchi)
  • Stop workspace symbol searches from warning when a workspace has not been
    built yet. (#1769, @smorimoto)
  • Prevent whole-document formatting requests for OCamllex, Menhir, and Cram
    files from being routed through Dune's S-expression formatter.
  • Refactor ppx hover to use merlin directly (#1606, fixes #1614)

CHANGES:

Features

  • Offer parenthesized application snippets for constructors with payloads, with
    independent argument slots, while retaining name-only completions. (#2212, @rgrinberg)
  • Make generated destruct branch bodies interactive for clients with snippet edit
    support. (#2204, @rgrinberg)
  • Offer whole-call completions for OCaml functions with multiple labelled or
    optional arguments, with editable slots for all arguments. (#2199, @rgrinberg)
  • Make generated construct completions interactive for clients with snippet support.
    (#2198, @rgrinberg)
  • Support ocp-indent as an alternative for document and range formatting.
    (#2148, @rgrinberg)
  • Support textDocument/onTypeFormatting through the optional, persistent
    ocp-indent-rpc helper. (#1986, @rgrinberg)
  • Report Dune RPC, build progress, and Merlin configuration process activity
    through LSP trace notifications. (#1899, @rgrinberg)
  • Add a code action to open the closest Dune file for the current document.
    (#1817, fixes #1491, @rgrinberg)
  • Distinguish operators from functions in semantic highlighting. (#1831, @rgrinberg)
  • Support textDocument/implementation for type declarations in interface files,
    including nested modules, functor results, includes, and aliases.
    (#2074, fixes #1163, @rgrinberg)
  • Classify function parameters and labels in semantic highlighting.
    (#1857, @rgrinberg)
  • Distinguish built-in from user-defined types in semantic highlighting.
    (#1858, fixes #1139, @rgrinberg)

Fixes

  • Avoid overlapping semantic tokens in with type constraints and destructive
    substitutions. (#2206, @rgrinberg)
  • Preserve nested or-patterns when formatting destruct-line case-analysis
    replies. (#2194, @rgrinberg)
  • Clear stale Dune diagnostics and promotion actions when an RPC instance exits,
    without removing a replacement instance for the same root. (#2189, @rgrinberg)
  • Ensure recovered selection ranges contain the requested position. (#2170,
    @rgrinberg)
  • Suppress function extraction when a constructor would move out of scope or
    resolve to a shadowing declaration. (#2169, @rgrinberg)
  • Clamp recovered selection ranges to the document bounds. (#2061, @rgrinberg)
  • Exclude symbol declarations from reference results when requested by the
    client. (#2164, @rgrinberg)
  • Convert related locations parsed from Merlin diagnostic messages to zero-based
    LSP line numbers. (#2163, fixes #2145, @rgrinberg)
  • Preserve trailing newlines when computing post-edit ranges. (#2159,
    @rgrinberg)
  • Return only inlay hints within the range requested by the client. (#2155,
    @rgrinberg)
  • Return document symbol kinds the client supports, falling back to
    Constructor and Class when it does not advertise the newer kinds.
    (#2122, fixes #2121, @dayangac)
  • Offer the unused-code quick fixes again: they matched diagnostic messages the
    server does not emit, and marking an unused open! produced open!!.
    (#2117, fixes #2116, @dayangac)
  • Offer to create a missing implementation or interface counterpart only when
    the client supports the create resource operation. (#2115, fixes #2114,
    @dayangac)
  • Tag unused and deprecated values in diagnostics, so clients can grey them out
    or strike them through. (#2110, fixes #2109, @dayangac)
  • Honor client support for deprecation tags in workspace-symbol results.
    (#2113, @rgrinberg)
  • Respect the client's folding range capabilities: omit character positions for
    lineFoldingOnly clients, omit unsupported folding range kinds, and honor
    rangeLimit. (#2099, fixes #911, @dayangac)
  • Classify module names in with constraints and in signature opens in
    semantic highlighting. (#2098, fixes #808, @dayangac)
  • Report a type when hovering a variant constructor or an exception where it is
    declared. (#2102, fixes #1300, @dayangac)
  • Return no location instead of failing the request when a definition,
    declaration or type definition cannot be found, so clients that request them
    eagerly no longer surface spurious errors. (#2100, fixes #1161, @dayangac)
  • Prefer a same-document related location when a Dune diagnostic has an empty
    primary range, such as ml/mli mismatches. (#2093, @rgrinberg)
  • Stop offering the inferred-interface code action when the interface already
    declares everything the implementation exports. (#2096, fixes #347, @dayangac)
  • Unregister Dune promotion code actions when an RPC instance finishes.
    (#2076, @rgrinberg)
  • Avoid unregistering promotion code actions when clearing the last promotion
    for an already open document. (#2075, @rgrinberg)
  • Find destruct-line cases after module-type constraints in match scrutinees.
    (#2072, @rgrinberg)
  • Keep Dune RPC registry polling responsive while connected instances are
    running. (#1919, @rgrinberg)
  • Fix the build on FreeBSD, where statfs(2) is declared in <sys/mount.h>
    rather than <sys/statfs.h>. (#2070, fixes #1069, @dayangac)
  • Deduplicate identical rename text edits returned by Merlin recovery.
    (#2064, @rgrinberg)
  • Reject cross-line destruct recovery locations before applying line-local
    source offsets. (#2063, @rgrinberg)
  • Use consistent document snapshots and versions when converting rename
    occurrences into workspace edits. (#2062, @rgrinberg)
  • Reject malformed destruct-line recovery replies and find match separators
    lexically instead of treating identifier substrings as with. (#2043, @rgrinberg)
  • Skip inline edit construction for bindings without applicable uses, avoiding
    stack exhaustion when printing deeply recovered expressions. (#2041, @rgrinberg)
  • Keep construct-completion text edits on the request line when Merlin recovery
    returns a multiline location. (#2034, @rgrinberg)
  • Advertise Dune promotion code actions using their returned quickfix kind.
    (#2055, @rgrinberg)
  • Reject interface documents passed to the ocamllsp/inferIntf custom request
    with InvalidParams. (#2051, @rgrinberg)
  • Report malformed type-enclosing custom-request parameters as InvalidParams
    instead of an internal error. (#2050, @rgrinberg)
  • Return null from the refactor-extract custom request for empty ranges.
    (#2049, @rgrinberg)
  • Return null from the destruct custom request for inapplicable ranges.
    (#2048, @rgrinberg)
  • Return null from the construct custom request when the cursor is not at a
    typed hole. (#2047, @rgrinberg)
  • Preserve deprecation status in workspace-symbol results. (#2044, @rgrinberg)
  • Render empty odoc tables in hover documentation without raising an internal
    error. (#2038, @rgrinberg)
  • Enable function parameter inlay hints when the client sends no configuration.
    (#2097, fixes #1371, @dayangac)
  • Respect client support for signature-help parameter-label offsets. (#2009,
    @rgrinberg)
  • Keep Merlin diagnostic ranges within document bounds. (#2008, @rgrinberg)
  • Suppress triggered completion and signature help inside comments after Unicode.
    (#1994, @rgrinberg)
  • Emit semantic tokens in source order so their relative positions remain valid.
    (#1992, @rgrinberg)
  • Stop stale signature help at expression boundaries. (#1987, fixes #1162,
    @rgrinberg)
  • Suppress signature help for completed applications. (#1982, #1162, @rgrinberg)
  • Encode remove-unused code-action edits using the client's negotiated position
    encoding. (#1969, @rgrinberg)
  • Exclude surrounding parentheses from infix operator rename placeholders and
    edits. (#1966, fixes #1190, @rgrinberg)
  • Suppress signature help for applications after the cursor. (#1965, #1162,
    @rgrinberg)
  • Use each document's current version in multi-file rename edits. (#1958, @rgrinberg)
  • Handle zero-work Dune build progress updates. (#1896, @rgrinberg)
  • Do not report Dune build progress when the client disables work-done progress.
    (#2082, @rgrinberg)
  • Reject malformed Dune promotion commands. (#2084, @rgrinberg)
  • Keep Dune promotion registrations balanced when diagnostics share a source.
    (#2089, @rgrinberg)
  • Reject negative JSON-RPC Content-Length headers. (#1873, @rgrinberg)
  • Report unsupported LSP request methods as unavailable instead of internal
    server errors. (#1862, @rgrinberg)
  • Advertise semantic-token support only to clients that declare the capability.
    (#1851, @rgrinberg)
  • Advertise semantic-token support only to clients that support the relative
    token format. (#1853, @rgrinberg)
  • Advertise semantic-token support only to clients that support full-document
    requests. (#1856, @rgrinberg)
  • Advertise semantic-token delta support only to clients that request it.
    (#1859, @rgrinberg)
  • Advertise and encode only semantic token types supported by the client.
    (#1860, @rgrinberg)
  • Advertise and encode only semantic token modifiers supported by the client.
    (#1978, @rgrinberg)
  • Offer the destruct-line code action on inline match expressions with
    incomplete cases. (#1829, fixes #1595, @rgrinberg)
  • Replace a lone polymorphic-variant backtick when applying completions.
    (#1823, fixes #1427, @rgrinberg)
  • Report a missing project build-system executable as a diagnostic without
    discarding the opened document. (#1814, @rgrinberg)
  • Advertise all code-action kinds that the server may return. (#1803, @rgrinberg)
  • Respect hierarchical code-action kind filters from clients. (#1802, @rgrinberg)
  • Ensure textDocument/documentSymbol returns a selectionRange contained
    within its range, so clients no longer reject the document outline.
    (#1775, fixes #1560, @Leonard013)
  • Recompute Merlin diagnostics when diagnostic shortening changes. (#1804, @rgrinberg)
  • Avoid eagerly computing inline code-action edits when clients support lazy
    resolution. (#1808, @rgrinberg)
  • Keep URI query parameters separate from filesystem paths. (#1776, @rgrinberg)
  • Preserve URI paths beginning with two slashes across serialization. (#1798, @rgrinberg)
  • Preserve percent-encoded URI fragments across parsing and serialization. (#1801, @rgrinberg)
  • Preserve URI paths whose first segment resembles a non-letter Windows drive. (#1800, @rgrinberg)
  • Preserve unescaped Unicode in URI query components. (#1799, @rgrinberg)
  • Preserve document offsets across incremental text edits. (#1777, @rgrinberg)
  • Respect the client's preferred completion documentation format. (#1885, @rgrinberg)
  • Parse non-ASCII completion prefixes and whitespace in CRLF input. (#1886, @rgrinberg)
  • Use constructor completion kinds when clients do not support enum members. (#1887, @rgrinberg)
  • Use completion deprecation tags when supported by the client. (#1903, @rgrinberg)
  • Keep completion sort keys lexically ordered beyond 9,999 items. (#1883, @rgrinberg)
  • Replace incorrect identifier suffixes when applying completions. (#1964, fixes #838, @rgrinberg)
  • Give synthetic completion items stable ordering metadata. (#1882, @rgrinberg)
  • Preserve dotted operators in completion prefixes and resolve requests. (#1890, @rgrinberg)
  • Correct code-action ranges after multiline text insertions. (#1748, @rgrinberg)
  • Allow clients to add their first workspace folder dynamically. (#1747, @rgrinberg)
  • Unregister Dune promotion commands after their diagnostics are cleared. (#1746, @rgrinberg)
  • Point workspace symbols for generated sources to their files in the build
    directory. (#1742, @tatchi)
  • Stop workspace symbol searches from warning when a workspace has not been
    built yet. (#1769, @smorimoto)
  • Prevent whole-document formatting requests for OCamllex, Menhir, and Cram
    files from being routed through Dune's S-expression formatter.
  • Refactor ppx hover to use merlin directly (#1606, fixes #1614)

This new release of OCaml-LSP brings several new features and improvements, including new custom requests, support for range formatting, and enhanced hover capabilities.

See the related announcement on the Discuss forums.

See full changelog

Features

  • Add custom ocamllsp/refactorExtract request (#1545)
  • Add destruct custom request (#1583)
  • Add locate_types custom request (#1584)
  • Add support for the textDocument/rangeFormatting request (#1591)
  • Allow to configure merlin using build systems other than dune. If $OCAMLLSP_PROJECT_BUILD_SYSTEM environment variable is set then OCaml LSP will execute $OCAMLLSP_PROJECT_BUILD_SYSTEM ocaml-merlin command to get merlin configuration for a module. It is expected the command to communicate using merlin-dot-protocol. If $OCAMLLSP_PROJECT_ROOT environment variable is set then OCaml LSP will use it as a project root directory.

Fixes

  • Enable "hover" on more locations, notably class and object related (#1599)

This release of ocaml-lsp-server introduces support for .mlx files, new custom requests, and configuration updates for code-lens.

Features

  • .mlx Support: Added support for .mlx files, including diagnostics, code actions, hover, and formatting via ocamlformat-mlx.
  • New Custom Requests: Added typeExpression, locate, and phrase requests to the server.
  • Code-Lens Configuration: code-lens for nested let bindings is now configurable.

Fixes and Improvements

  • Configuration Fallback: The server now falls back to .merlin configuration if a dune-project file is missing, provided dot-merlin-reader is installed.
  • Metrics: Improved the precision of timestamps for collected metrics.
See full changelog

Features

  • Make code-lens for nested let bindings configurable (#1567)
  • Add support for .mlx files, including formatting via ocamlformat-mlx and most OCaml LSP features (diagnostics, code actions, hover, etc.) (#1528)
  • Add typeExpression custom request (#1576)
  • Add locate custom request (#1576)
  • Add phrase custom request (#1576)

Fixes

  • Improve precision of collected metrics timestamps. (#1565)
  • Fallback on .merlin configuration if no dune-project file is found and if dot-merlin-reader is installed. (#1563, fixes #1522)

We're happy to announce the release of ocaml-lsp-server 1.23.1!

This maintenance release fixes three key issues:

  • Method hover now works: Hovering over object method calls now correctly displays type information instead of showing "No information available"
  • OCamllex files open without errors: Fixed an error that occurred when opening .mll (OCamllex lexer) files in editors like NeoVim
  • Yojson compatibility: Ensures the language server works with both yojson 2.0 and 3.0

Update via opam: opam update && opam upgrade ocaml-lsp-server

For more details, see the related announcement on the Discuss forums!

See full changelog

Fixes

  • Fix hover on method calls not showing the type. (#1553, fixes #1552)
  • Fix error on opening .mll files (#1557)
  • Ensure compatibility with both yojson 2.0 and 3.0. (#1534)

TL;DR

ocaml-eglot provides full OCaml language support in Emacs through the Language Server Protocol (LSP) instead of direct Merlin integration. It offers the same features as merlin.el with simplified setup and enhanced capabilities like project-wide search. If you're starting fresh or want a more standardized approach, try ocaml-eglot, which is actively maintained. If your current merlin.el setup works well, you can continue using it.

Quick start: Install ocaml-lsp-server, add ocaml-eglot to your Emacs config, and get the same OCaml development experience with less configuration.

What is ocaml-eglot?

ocaml-eglot connects Emacs to ocaml-lsp-server using the Language Server Protocol, providing a standardized way to get OCaml language support.

Since the recent versions of Emacs (29), eglot, an LSP client, has been shipped with Emacs. However, merlin.el provides more features than LSP (which is designed to be generic), so relying solely on the features of LSP and eglot would limit functionality. Thus, we extended the LSP server to support more features, and ocaml-eglot allows you to benefit from these features in Emacs.

ocaml-eglot is a minor mode. It therefore works in conjunction with a major mode to edit Caml code. Examples of major modes include tuareg, caml-mode and the recent neocaml.

Who Should Use ocaml-eglot?

Use ocaml-eglot if you:

  • Are starting fresh with OCaml
  • If you use or want to use Emacs
  • Want simplified configuration with automatic setup
  • Use multiple editors and want consistent OCaml support
  • Want access to project-wide search and rename features
  • Want to rely on an actively maintained project that evolves over time

If your current setup is working perfectly and is heavily customised, merlin.el will still keep working, so there's no immediate need to migrate. However, for the moment, we don't plan to actively maintain merlin.el -- unless we receive a lot of requests.

Getting Started

Follow the installation instructions in the ocaml-eglot README.

When migrating from merlin.el to ocaml-eglot, your existing keybindings should work immediately!

Features

Error Navigation: Quick jump to next/previous errors

Type Information: Display types under cursor with adjustable verbosity, navigate enclosing expressions

Code Generation: Pattern matching construction, case completion, wildcard refinement via "destruct" feature

Navigation: Jump between language constructs (let, module, function, match), navigate phrases and pattern cases

Search: Find definitions, declarations, and references

For a detailed list of features, see the ocaml-eglot README.

Next Steps

  1. Try the basic setup with an existing OCaml project
  2. Explore all the features of ocaml-eglot
  3. Provide feedback at ocaml-eglot's GitHub Issues

Documentation

Related Releases

On January 17, 2025, ocaml-eglot version 1.0.0 was released, providing a new minor emacs mode to enable the editor features provided by ocaml-lsp-server. Subsequent releases 1.1.0 and 1.2.0 enable support for flycheck as a configurable alternative to flymake (1.0.0 release), Emacs 30.1 support, better user experience and error handling, as well as support for new features.

We're pleased to announce the release of OCaml LSP Server 1.23.0!

See full changelog

Features

  • Make inlay-hint for function parameters configurable (#1515)
  • Add custom ocamllsp/jumpToTypedHole to navigate through typed holes (#1516)
  • Add a code-action for combining pattern cases (just relaying on regex) (#1514)
  • Allow (by configuration) shortening of diagnostics (just highlighting the first line) (#1513)
  • Fix yojson_of_t for Nullable_option: serialize None as Null instead of asserting false (#1525 fixes #1524)

Fixes

  • Support for class, class type, method and property for DocumentSymbol query (#1487 fixes #1449)
  • Fix inlay-hint for function parameters (#1515)
  • More precise diagnostics in the event of a failed identifier search (Definition_query) (#1518)
  • Remove ocamlformat application after destruct (that remove some useful parenthesis) (#1519)

We're pleased to announce the release of OCaml LSP Server 1.21.0-4.14!

See full changelog

Features

  • Make inlay-hint for function parameters configurable (#1515)

  • Add custom ocamllsp/jumpToTypedHole to navigate through typed holes (#1516)

  • Add a code-action for combining pattern cases (just relaying on regex) (#1514)

  • Allow (by configuration) shortening of diagnostics (just highlighting the first line) (#1513)

  • Fix yojson_of_t for Nullable_option: serialize None as Null instead of asserting false (#1525 fixes #1524)

Fixes

  • Support for class, class type, method and property for DocumentSymbol query (#1487 fixes #1449)

  • Fix inlay-hint for function parameters (#1515)

  • More precise diagnostics in the event of a failed identifier search (Definition_query) (#1518)

  • Remove ocamlformat application after destruct (that remove some useful parenthesis) (#1519)

  • Add a new server option standardHover, that can be used by clients to
    disable the default hover provider. When standardHover = false
    textDocument/hover requests always returns with empty result. (#1416)

We're pleased to announce the release of OCaml LSP Server 1.22.0, which enables experimental project-wide renaming of identifiers!

See full changelog

Features

  • Enable experimental project-wide renaming of identifiers (#1431)

OCaml LSP Server version 1.21.0 is now available. This release introduces a new server option called standardHover that allows clients to disable the default hover provider functionality.

See full changelog

Features

  • Add a new server option standardHover, that can be used by clients to
    disable the default hover provider. When standardHover = false
    textDocument/hover requests always returns with empty result. (#1416)

We are excited to share the release of OCaml-LSP 1.20.1, which introduces powerful new features and vital bug fixes to improve your development workflow. The new typeSearch request allows you to find values by type signature or polarity, making it easier to locate the functionality you need. Configurable MerlinJump actions and the custom jump request give you more control over code navigation. On the bug fix side, we have tackled issues like file descriptor leaks, enhanced method completion, and cleaned up duplicate responses in selectionRange.

See full changelog

Features

  • Add custom ocamllsp/typeSearch request (#1369)
  • Make MerlinJump code action configurable (#1376)
  • Add custom ocamllsp/jump request (#1374)

Fixes

  • Deactivate the jump code actions by default. Clients can enable them with the merlinJumpCodeActions configuration option. Alternatively, a custom request is provided for ad hoc use of the feature. (#1411)
  • Fix FD leak in running external processes for preprocessing (#1349)
  • Fix prefix parsing for completion of object methods (#1363, fixes #1358)
  • Remove some duplicates in the selectionRange answers (#1368)

We are pleased to announce the release of OCaml LSP 1.19.0. This version brings official support for OCaml 5.2. It also includes a new custom query to get

documentation and a fix regarding the handling of OCamlFormat processes.

See full changelog

Features

Fixes

  • Kill unnecessary OCamlFormat processes with sigterm rather than sigint or sigkill (ocaml/ocaml-lsp#1343)

We are pleased to announce the release of OCaml LSP 1.18.0. This version comes with a lot of fixes and new features.

Notable features that are included in this release are:

  • Improved hover behavior with less noisy hovers on some parse tree nodes such as keywords, comments, etc., along with support for hovering over PPX annotations and preview the generated code.
  • Some additional custom queries, particularly TypeEnclosing
  • Folding ifthenelse expressions
  • A new configuration option to control Dune diagnostics
  • Improved document symbols

...and many fixes to a handful of issues.

Feedback is very much welcomed on the the Discuss Announcement post and do not hesistate to report issues in the issue tracker.

See full changelog

Features

  • Introduce a configuration option to control Dune diagnostics. The option is called duneDiganostics, and it may be set to { enable: false } to disable diagnostics. (ocaml/ocaml-lsp#1221)

  • Support folding of ifthenelse expressions (ocaml/ocaml-lsp#1031)

  • Improve hover behavior (ocaml/ocaml-lsp#1245)

    Hovers are no longer displayed on useless parse tree nodes such as keywords, comments, etc.

    Multiline hovers are now filtered away.

    Display expanded PPXs in the hover window.

  • Improve document symbols (ocaml/ocaml-lsp#1247)

    Use the parse tree instead of the typed tree. This means that document symbols will work even if the source code doesn't type check.

    Include symbols at arbitrary depth.

    Differentiate functions / types / variants / etc.

    This now includes PPXs like let%expect_test or let%bench in the outline.

  • Introduce a destruct-line code action. This is an improved version of the old destruct code action. (ocaml/ocaml-lsp#1283)

  • Improve signature inference to only include types for elements that were absent from the signature. Previously, all signature items would always be inserted. (ocaml/ocaml-lsp#1289)

  • Add an update-signature code action to update the types of elements that were already present in the signature (ocaml/ocaml-lsp#1289)

  • Add custom ocamllsp/merlinCallCompatible request (ocaml/ocaml-lsp#1265)

  • Add custom ocamllsp/typeEnclosing request (ocaml/ocaml-lsp#1304)

Fixes

  • Detect document kind by looking at Merlin's suffixes config.

    This enables more LSP features for non-.ml/.mli files. Though it still depends on Merlin's support. (ocaml/ocaml-lsp#1237)

  • Correctly accept the --clientProcessId flag. (ocaml/ocaml-lsp#1242)

  • Disable automatic completion and signature help inside comments (ocaml/ocaml-lsp#1246)

  • Includes a new optional/configurable option to toggle syntax documentation. If toggled on, allows display of syntax documentation on hover tooltips. Can be controlled via environment variables and by GUI for VS code. (ocaml/ocaml-lsp#1218)

  • For completions on labels that the LSP gets from Merlin, take into account whether the prefix being completed starts with ~ or ?. Change the label completions that start with ? to start with ~ when the prefix being completed starts with ~. (ocaml/ocaml-lsp#1277)

  • Fix document syncing (ocaml/ocaml-lsp#1278, ocaml/ocaml-lsp#1280, fixes ocaml/ocaml-lsp#1207)

  • Stop generating inlay hints on generated code (ocaml/ocaml-lsp#1290)

  • Fix parenthesising of function types in SignatureHelp (ocaml/ocaml-lsp#1296)

  • Fix syntax documentation rendering (ocaml/ocaml-lsp#1318)

We are pleased to announce the release of OCaml LSP 1.17.0. This version comes packed with fixes and new features.

Notable features that come in this release include:

  • Compatibility with Odoc 2.3.0: This version is fully compatible with Odoc 2.3.0, introducing support for the latest syntax features like tables and "codeblock output."
  • New Actions for Code Cleanup: You can now mark or remove unused elements such as 'open', types, for loop indexes, modules, match cases, 'rec', and constructors, making your code cleaner and more efficient.
  • Auto-completion for 'in' Keyword: To address the long standing issue of the in keyword completing to other terms in the editor, we've added auto-completion for this keyword in OCaml LSP. Typing in will now only suggest auto completion for the in keyword.
See full changelog

Fixes

  • Fix missing super & subscripts in markdown documentation. (#1170)
  • Do not invoke dune at all if --fallback-read-dot-merlin flag is on. (#1173)
  • Fix semantic highlighting of infix operators that contain '.'. (#1186)
  • Disable highlighting unit as an enum member to fix comment highlighting bug. (#1185)
  • Improve type-on-hover and type-annotate efficiency by only formatting the type of the first enclosing. (#1191, #1196)
  • Fix the encoding of URI's to match how vscode does it (#1197)
  • Fix parsing of completion prefixes (#1181)

Features

  • Compatibility with Odoc 2.3.0, with support for the introduced syntax: tables, and "codeblock output" (#1184)
  • Display text of references in doc strings (#1166)
  • Add mark/remove unused actions for open, types, for loop indexes, modules, match cases, rec, and constructors (#1141)
  • Offer auto-completion for the keyword in (#1217)

We've released OCaml LSP 1.16.2 with a fix that was introduced in 1.16.1 that prevented users from using preprocessor such as CPPO.

See full changelog

Fixes

  • Fix file permissions used when specifying output files of pp and ppx. (ocaml-lsp#1153)

We're thrilled to announce the release of OCaml LSP 1.16.1! 🎉

This release comes with new "Extract local" and "Extract function" code actions to easily refactor your code.

We've also disabled code lenses by default following user feedback. You can follow the discussion on GitHub.

This release is also the first OCaml LSP release to use upstream Merlin. Among other things, this means that it is compatible with all the OCaml versions supported by Merlin: currently OCaml 4.14 and 5.0.0.

We're also releasing numerous bug fixes, including:

  • A fix to the integration with Dune RPC on Windows, which, alongside Dune 3.9.0, makes OCaml LSP report Dune errors to the editors with Dune watch mode enabled.
  • Minor improvements to the Odoc <-> Markdown conversion to return better function documentation on the editor.

And much more! Read the full changelog for a complete list of improvements and bug fixes.

See full changelog

Features

  • Add "Remove type annotation" code action. (#1039)
  • Support settings through didChangeConfiguration notification (#1103)
  • Add "Extract local" and "Extract function" code actions. (#870)
  • Depend directly on merlin-lib 4.9 (#1070)

Fixes

  • Support building with OCaml 5.0 and 5.1 (#1150)

  • Disable code lens by default. The support can be re-enabled by explicitly setting it in the configuration. (#1134)

  • Fix initilization of ocamlformat-rpc in some edge cases when ocamlformat is initialized concurrently (#1132)

  • Kill unnecessary $ dune ocaml-merlin with SIGTERM rather than SIGKILL (#1124)

  • Refactor comment parsing to use odoc-parser and cmarkit instead of octavius and omd (#1088)

    This allows users who migrated to omd 2.X to install ocaml-lsp-server in the same opam switch.

    We also slightly improved markdown generation support and fixed a couple in the generation of inline heading and module types.

  • Allow opening documents that were already open. This is a workaround for neovim's lsp client (#1067)

  • Disable type annotation for functions (#1054)

  • Respect codeActionLiteralSupport capability (#1046)

  • Fix a document syncing issue when utf-16 is the position encoding (#1004)

  • Disable "Type-annotate" action for code that is already annotated. (#1037, fixes #1036)

  • Fix semantic highlighting of long identifiers when using preprocessors (#1049, fixes #1034)

  • Fix the type of DocumentSelector in cram document registration (#1068)

  • Accept the --clientProcessId command line argument. (#1074)

  • Accept --port as a synonym for --socket. (#1075)

  • Fix connecting to dune rpc on Windows. (#1080)

On behalf of the ocaml-lsp team, I’m pleased to announce ocaml-lsp-server versions 1.15.0-4.14 and 1.15.0-5.0 for OCaml 4.14 and 5.0, respectively. This is the first time we release ocaml-lsp supporting two compiler versions. We look forward to your feedback.

See full changelog

Features

  • Enable semantic highlighting support by default (#933)

  • Support connecting over pipes and socket. Pipes on Windows aren't yet supported (#946)

    More about communication channels in LSP specification.

  • Re-enable ocamlformat-rpc for formatting code snippets (but not files and not on Windows) (#920, #939)

    One needs to have installed either ocamlformat package version > 0.21.0 or, otherwise, ocamlformat-rpc package. Note that previously ocamlformat-rpc came in a standalone OPAM package, but since ocamlformat version > 0.21.0, it comes within ocamlformat package.

  • Add custom ocamllsp/hoverExtended request (#561)

  • Support utf-8 position encoding clients (#919)

    More about position encoding in LSP specification.

  • Show unwrapped module alias types on hovering over module names. This is due to upgrading to merlin 4.7 and using merlin's verbosity=smart by default (#942)

Fixes

  • Respect the client's completion item resolve and preSelect capabilities (#925, #936)

  • Disable polling for dune's watch mode on Windows and OCaml 4.14.0 (#935)

  • Fix semantic highlighting of "long identifiers," e.g., Foo.Bar.x (#932)

  • Fix syncing of document contents:

    • For ranges that span an entire line (#927)
    • Previously, whole line edits would incorrectly eat the newline characters (#971)
See full changelog

Fixes

  • Fix random requests failing after switching documents (#904, fixes #898)

  • Do not offer related diagnostic information unless the user enables in client capabilities (#905)

  • Do not offer diagnostic tags unless the client supports them (#909)

  • Do not attach extra data to diagnostics unless the client supports this (#910)

  • Use /bin/sh instead of /bin/bash. This fixes ocamllsp on NixOS

See full changelog

Fixes

  • Fix various server crashes when opening non OCaml/Reason files. Files such as dune, cram, etc. would cause the server to crash. (#884, fixes #871)

  • Ignore unknown tags in merlin configuration to improve forward compatibility with Dune. (#883)

On behalf of the ocamllsp team, I'm pleased to announce version 1.14.0. This release contains a new code action to help you inline definitions thanks to @jfeser. We look forward to your feedback.

See full changelog

Features

  • Code action for inlining let bindings within a module or expression. (#847)

  • Tag "unused code" and "deprecated" warnings, allowing clients to better display them. (#848)

  • Refresh merlin configuration after every dune build in watch mode (#853)

Fixes

  • Respect showDocument capabilities. Do not offer commands or code actions that rely on this request without client support. (#836)

  • Fix signatureHelp on .mll files: avoid "Document.dune" exceptions

See full changelog
  • Allow cancellation of workspace symbols requests (#777)

  • Fix unintentionally interleaved jsonrpc IO that would corrupt the session (#786)

  • Ignore SIGPIPE . (#788)

See full changelog

Fixes

  • Fix a bad interaction between inferred interfaces and promotion code actions in watch mode (#753)

  • Fix URI parsing (#739 fixes #471 and #459)

See full changelog

Features

  • Fix cancellation mechanism for all requests (#707)

  • Allow cancellation of formatting requests (#707)

  • Add --fallback-read-dot-merlin to the LSP Server (#705). If ocamllsp is started with this new flag, it will fall back to looking for Merlin configuration in .merlin files rather than calling dune ocaml-merlin. (#705)

  • Support folding more ranges (#692)

See full changelog
  • Fix process termination. Once the lsp server is stepped, the process will gracefully terminate (#697, fixes #694)

  • Forward stderr from dune's merlin configuration to the lsp server's stderr (#697)

On behalf of the ocamllsp team, I’m excited to announce the availability of version 1.11.0. This release is an important milestone for the project because it introduces integration with our favorite build system. When you run dune in watch mode, you will now be able to see build errors in the diagnostics panel of your editor. It’s all rather experimental for now, so your feedback and bug reports are appreciated.

As usual, the full change log is below.

Happy hacking.

See full changelog

Features

  • Add support for dune in watch mode. The lsp server will now display build errors in the diagnostics and offer promotion code actions.

  • Re-introduce ocamlformat-rpc (#599, fixes #495)

Fixes

  • Fix workspace symbols that could have a wrong path in some cases (#675)

On behalf of the ocamllsp team, I’m pleased to announce version 1.10.0. The only new feature this release offers is better code folding, but there are some important bug fixes and performance improvements. If you encounter any sluggishness with our server, do not hesitate to report it.

Unless there are serious bugs with this release, this will be the last release for OCaml 4.13.

Happy Hacking.

See full changelog

Features

  • Add better support for code folding: more folds and more precise folds

Fixes

  • Fix infer interface code action crash when implementation source does not exist (#597)

  • Improve error message when the reason plugin for merlin is absent (#608)

  • Fix chdir races when running ppx (#550)

  • More accurate completion kinds. New completion kinds for variants and fields. Removed inaccurate completion kinds for constructors and types. (#510)

  • Fix handling request cancellation (#616)

See full changelog

Fixes

  • Ppx processes are now executed correctly (#513)

Breaking Change

  • ocamllsp drops support for .merlin files, and as a consequence no longer depends on dot-merlin-reader. (#523)

Features

  • New code action to automatically remove values, types, opens (#502)
See full changelog
  • Fix debouncing of document updates. It was essentially completely broken in all but the most trivial cases. (#509 fixes #504)

  • Fix completion when passing named and functional arguments (#512)

On behalf of the ocaml-lsp team, I’m pleased to announce version 1.8.0. This release contains some quality of life bug fixes, better diagnostics locations, and a few new code actions. Happy hacking.

See full changelog

Features

  • Add a new code action Add missing rec keyword, which is available when adding a rec keyword can fix Unbound value ... error, e.g.,

    let fact n = if n = 0 then 1 else n * fact (n - 1)
                                      (* ^^^^ Unbound value fact *)
    

    Adding rec to the definition of fact will fix the problem. The new code action offers adding rec.

  • Use ocamlformat to properly format type snippets. This feature requires the ocamlformat-rpc opam package to be installed. (#386)

  • Add completion support for polymorphic variants, when it is possible to pin down the precise type. Examples (<|> stands for the cursor) when completion will work (#473)

    Function application:

    let foo (a: [`Alpha | `Beta]) = ()
    
    foo `A<|>
    

    Type explicitly shown:

    let a : [`Alpha | `Beta] = `B<|>
    

    Note: this is actually a bug fix, since we were ignoring the backtick when constructing the prefix for completion.

  • Parse merlin errors (best effort) into a more structured form. This allows reporting all locations as "related information" (#475)

  • Add support for Merlin Construct command as completion suggestions, i.e., show complex expressions that could complete the typed hole. (#472)

  • Add a code action Construct an expression that is shown when the cursor is at the end of the typed hole, i.e., _|, where | is the cursor. The code action simply triggers the client (currently only VS Code is supported) to show completion suggestions. (#472)

  • Change the formatting-on-save error notification to a warning notification (#472)

  • Code action to qualify ("put module name in identifiers") and unqualify ("remove module name from identifiers") module names in identifiers (#399)

    Starting from:

    open Unix
    
    let times = Unix.times ()
    let f x = x.Unix.tms_stime, x.Unix.tms_utime
    

    Calling "remove module name from identifiers" with the cursor on the open statement will produce:

    open Unix
    
    let times = times ()
    let f x = x.tms_stime, x.tms_utime
    

    Calling "put module name in identifiers" will restore:

    open Unix
    
    let times = Unix.times ()
    let f x = x.Unix.tms_stime, x.Unix.tms_utime
    

Fixes

  • Handle workspace change notifications. Previously, the server would only use the set of workspaces given at startup to search for workspace symbols. After this change, workspace folders that are added later will also be considered. (#498)

  • Do not show "random" documentation on hover

  • Correctly rename a variable used as a named/optional argument (#478)

  • When reporting an error at the beginning of the file, use the first line not the second (#489)

See full changelog

Features

  • Add sub-errors as "related" information in diagnostics (#457)

  • Add support for navigating to a symbol inside a workspace (#398)

  • Show typed holes as errors

    Merlin has a concept of "typed holes" that are syntactically represented as _. Files that incorporate typed holes are not considered valid OCaml, but Merlin and OCaml-LSP support them. One example when such typed holes can occur is when on "destructs" a value, e.g., destructing (Some 1) will generate code match Some 1 with Some _ -> _ | None -> _. While the first underscore is a valid "match-all"/wildcard pattern, the rest of underscores are typed holes.

If you want to contribute to a new release announcement, check out the Contributing Guide on GitHub.