Backstage OCaml

RSS

Get updates on experimental releases, work-in-progress, and opportunities to contribute to the development of the OCaml Platform and its infrastructure.

CHANGES:

Features

  • 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)

Fixes

  • 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)
  • 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)
  • 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)
  • Ensure textDocument/documentSymbol returns a selectionRange contained
    within its range, so clients no longer reject the document outline.
    (#1775, fixes #1560, @Leonard013)
  • 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)
  • 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)

Discuss this post on discuss!

Merlin's signature-help feature, which displays function signatures and highlights the active parameter as you type, has received several improvements:

  • Parameter-only display: Signature help now only appears on function parameters, no longer on the function name itself.
  • No more parameter looping: After the last parameter, the highlight no longer wraps back to the first one.
  • Better context support: Signature help now activates within let .. in bindings even before the in keyword is written.
  • Optional parameter detection: Optional parameters are now correctly detected and highlighted when the user starts writing one.

Some of these improvements are already available in the latest Merlin and ocaml-lsp releases, with the rest coming in upcoming versions.

A preview release of OCaml-LSP for the OCaml 5.5 series is available. Notable changes:

  • A new destruct custom request (#1583), intended to let clients such as ocaml-eglot trigger the command directly rather than through a code action.
  • Configurable Merlin via build systems other than dune, through the OCAMLLSP_PROJECT_BUILD_SYSTEM and OCAMLLSP_PROJECT_ROOT environment variables (#1581).
  • Long signatures returned by signature-help are now formatted with ocamlformat for improved readability (#1580).

For more details, see the full changelog below.

See full backstage

Fixes

  • Improve the readability of signature-help for long signatures (#1580)

Features

  • Add destruct custom request (#1583)

  • 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.

Discuss this post on discuss!

We're excited to announce ocaml.nvim, a new Neovim plugin actively being developed by Tarides that brings advanced OCaml development features to Neovim users. Think of it as the Neovim sibling of ocaml-eglot, which we released earlier this year for Emacs users.

What is ocaml.nvim?

Modern code editors communicate with programming languages through the Language Server Protocol (LSP), which provides essential features like syntax checking, code navigation, and auto-completion. However, OCaml's language server exposes powerful custom commands beyond what generic LSP clients can access.

ocaml.nvim works alongside generic Neovim LSP plugins like nvim-lspconfig, providing direct access to advanced ocamllsp features without requiring complex editor-side logic. The plugin gives you access to all the advanced Merlin commands not supported by generic LSP clients.

Key Features

Typed Holes Navigation - Navigate between typed holes (_) and interactively substitute them with the Construct command.

Semantic Navigation - Move through your code semantically: jump between expressions, parent let bindings, modules, functions, and match expressions.

Phrase Navigation - Move between OCaml phrases (top-level definitions) in your buffer.

Many more features are in development, including alternating between .ml and .mli files, type enclosing, and pattern matching generation.

Getting Started

Installation is straightforward with lazy.nvim:

require("lazy").setup({
  { "tarides/ocaml.nvim",
    config = function()
      require("ocaml").setup()
    end
  }
})

The plugin complements your existing LSP setup—you'll continue to use Neovim's built-in LSP for standard features while ocaml.nvim adds OCaml-specific capabilities.

Project Status

The ocaml.nvim repository is now public on GitHub, with comprehensive documentation, a feature table, and screencast demonstrations. We're working towards a stable 1.0 release and welcome feedback from the community.

Try out ocaml.nvim and let us know what you think! For questions or feedback, reach out to Charlène Gros at charlene@tarides.com, join the discussion on the OCaml Discuss forum, or post an issue on the ocaml.nvim GitHub repository.

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