Skip to content

Changelog: Announce ocaml-eglot #3080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sabine
Copy link
Collaborator

@sabine sabine commented Apr 29, 2025

TODO:

  • check that all the examples / commands listed here work
  • get approval from @xvw on content

Resolves https://github.com/tarides/squad-adex/issues/40

@sabine sabine marked this pull request as draft April 29, 2025 13:54
@bbatsov
Copy link
Contributor

bbatsov commented May 19, 2025

I think that Eglot worked with OCaml ever before, but ocaml-eglot provides more features and a more polished user experience.

Are there really plans to sunset merlin-mode? Perhaps it's a bit premature for that.

@sabine sabine changed the title (data) Draft a post on ocaml-eglot for the Changelog Changelog: Announce ocaml-eglot Jul 30, 2025
Copy link
Contributor

@xvw xvw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sabine!


## 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`. If your current `merlin.el` setup works well, you can continue using it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the statement about merlin.el is generally true, I think it is important to mention that the evolution of ocaml-eglot is more sustainable because it is maintained, which is not really the case with merlin.el.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also worth mentioning that 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.


## 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. This eliminates editor-specific integrations while preserving all OCaml-specific features.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth mentioning that since the recent versions of Emacs (29), Eglot, an lsp client, has been shipped with Emacs. It is therefore reasonable to use ocaml-lsp-server to provide IDE services (standardising the experience for users of multiple languages). However, LSP is designed to be generic, so relying solely on the features of LSP and Eglot limits functionality and offers fewer features than merlin.el. That is why the server has been extended to support more features, and ocaml-eglot allows you to benefit from these features in Emacs, in conjunction with eglot.

- Your current setup is working perfectly and heavily customized
- You prefer direct Merlin communication

Both approaches are fully supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what ‘fully supported’ means in this context. I think we can say that, for the moment, we don't plan to provide any special support for merlin.el unless we receive a lot of requests.

## Getting Started

### Prerequisites
- Emacs 29.1+ (includes Eglot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user is using an earlier version, Eglot can still be installed.

- Emacs 29.1+ (includes Eglot)
- `opam install ocaml-lsp-server ocamlformat`

### Basic Setup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want to list the installation procedures in the changelog when they are already well documented in the README (and this potentially means maintaining the procedure in two different places)?

Comment on lines +87 to +99
## Essential Commands

| Feature | Command | Key Binding |
|---------|---------|-------------|
| Show type | `ocaml-eglot-type-enclosing` | `C-c C-t` |
| Jump to definition | `ocaml-eglot-find-definition` | `C-c C-l` |
| Jump to declaration | `ocaml-eglot-find-declaration` | `C-c C-i` |
| Generate patterns | `ocaml-eglot-destruct` | `C-c \|` |
| Fill holes | `ocaml-eglot-construct` | `C-c \` |
| Switch .ml/.mli | `ocaml-eglot-alternate-file` | `C-c C-a` |
| Show documentation | `ocaml-eglot-document` | `C-c C-d` |
| Search by type | `ocaml-eglot-search` | |
| Rename symbol | `ocaml-eglot-rename` | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can point to the README for a detailed list of features, right?

# Then use ocaml-eglot-rename in Emacs
```

**Polarity search**: Find functions by input/output types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is also available in merlin.el

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And I think that search by types is better, search by polarity is historically present).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants