[ANN] Release of ocaml-eglot 1.0.0

[ANN] Release of ocaml-eglot 1.0.0

Hi everyone!

We (at Tarides) are particularly pleased to announce the first release of OCaml-eglot, An overlay on Eglot (the built-in LSP client for Emacs) for editing OCaml!

More precisely

Typically, developers who use Emacs (43.7% in 2022, according to the OCaml User Survey) use a major mode (such as the venerable caml-mode, or tuareg) and Merlin to provide IDE services. In 2016, Microsoft has released LSP, a generic protocol for interacting with editors which, at first, was only used by Visual Studio Code, but, since 2020, has really become the norm. De-facto, following the LSP standard gives very good default (completion, jump to definition, …). OCaml has excellent LSP (ocaml-lsp-server) support, which is used in particular by the OCaml platform for Visual Studio Code.

With the aim of reducing maintenance for all possible editors, going LSP seems to be a good direction. A pertinent choice, especially since the major historical editors (such as Vim and Emacs) offer, in their recent versions, LSP clients out of the box. However, in the same way that the OCaml client for VSCode integrates OCaml-specific features, it was necessary to support these features on the Emacs side (and in the future, Vim) to compete with Merlin, which is the goal of ocaml-eglot, to provide a tailored development experience for OCaml code editing!

User feedback and future development

We’ve just released the first version of OCaml-eglot, and, much like the various editor-related projects (Merlin, Vscode-ocaml-platform, Merlin for Emacs, Merlin for Vim), we’re more than open to community collaboration, user feedback, in order to provide the best possible user experience!

Happy Hacking!

20 Likes

Yesterday I spent a nice afternoon integrating all of the functionality of ocaml-eglot into my emacs config, and I’d just like to share how nice the experience was. Everything worked just as I expected, the operations are easily composed, and working with the search, construction, and deconstruction feels amazing. Kudos and many thanks!

3 Likes

just curious, is there a specific reason eglot was chosen instead of lsp-mode, other than the fact that eglot is shipped by default with recent emacs?

The main reason being, as you point out, that yes, Eglot is shipped by default with Emacs since 29.1 (Which seems to me to be a valid reason, doesn’t it? After all, I know that @lambda_foo has had convincing experiences with Lsp-mode).

Is it possible to use ocaml-eglot without dune ?


P.S. It’s difficult to actually understand what ocaml-eglot is from your announce.

1 Like

I love that it’s built on top of eglot and flymake. As an Emacs user, I don’t want to shadow built-in stuff that works fine with third-party alternatives.

1 Like

P.S. It’s difficult to actually understand what ocaml-eglot is from your announce.

Arf! Sorry about that!
OCaml-eglot is a minor mode, Emacs, which is an alternative to Merlin mode, but uses the OCaml LSP Server rather than the OCamlmerlin Server. The main aim is to standardize clients across multiple editors.
(One might wonder why an additional minor mode is needed, if Eglot already does the interaction between an LSP server and Emacs, but this is partly to support all the OCaml-related specifics (specific commands), which allows OCaml eglot to be approximately ISO to Merlin. I hope that’s clearer?)

Is it possible to use ocaml-eglot without dune ?

Yes, but in the next few days I’ll try to simplify the invocation of the LSP server from Emacs by taking .merlin into account and add a note in the README!

1 Like

Yes. Thank you very much.

Out of curiosity. Any comments on the politics between the teams (if different ?) between the merlin project and the ocaml-lsp-server ? Are both project expected to continue separately or is merlin merging into ocaml-lsp-server or something like that ?

The two projects are jointly maintained (and share contributors) and will evolve together, but Merlin is an LSP dependency.

1 Like

Late last year I started hacking with the goal of writing elisp to call the experimental capabilities that ocaml-lsp-server exposes and integrating that with lsp-mode rather than eglot. Why because I was using lsp-mode for other languages (Rust, Haskell and C++) so it made sense. Plus merlin-mode and lsp-mode would both try to startup their own merlin command and get conflicts. I’m busy with other things right now and haven’t had time to finish it off.

Having a brief look at ocaml-eglot a version for lsp-mode wouldn’t be that much different in structure. Some of the jsonrpc request methods and lsp-mode plumbing would need to change. I’d hope that both modes would eventually get supported. In general I think the intent is right from an Emacs perspective, we want to drive all editor integration over LSP messages and not rely on other locally installed binaries like merlin.

1 Like

It’s definitely a very interesting point and I imagine that we can mutualize the fundamental code of ocaml-eglot, for example in a dedicated library to describe ocaml-eglot and ocaml-lsp-mode (?) with the most common code? In any case, it’s a project that deserves a collaborative boost!