Skip to content

Add tuareg interface mode#327

Open
PizieDust wants to merge 4 commits into
ocaml:masterfrom
PizieDust:tuareg_interface
Open

Add tuareg interface mode#327
PizieDust wants to merge 4 commits into
ocaml:masterfrom
PizieDust:tuareg_interface

Conversation

@PizieDust

@PizieDust PizieDust commented Jun 2, 2026

Copy link
Copy Markdown

Purpose

This PR introduces a new major-mode for .mli and .eliomi files as an opt-in feature
The necessity for this change comes from working on adding support for OCaml navigation in Combobulate.

Background

Tuareg uses one major-mode for .mli and .ml files, of which both file types have a separate tree-sitter grammar.
In Combobulate, we define two combobulate languages: ocaml and ocaml-interface, to handle both file types.
However, since with Tuareg we have a single major-mode for both file types, this led to an issue where when we activate Combobulate, the wrong parser is created in the buffer, as both parsers are able to attach to tuareg-mode. Introducing a new tuareg-interface-mode means we can disambiguate the Combobulate languages based on what the major mode is.

Method

By taking advantage of Emacs' standard define-derived-mode macro, we have defined tuareg-interface-mode as a child mode of tuareg-mode. Because of how Emacs constructs derived modes:

  • tuareg-interface-mode will automatically inherit all parent behaviors (indentation engine, syntax tables, highlighting configurations, font-locks, and the keymap tuareg-mode-map).
  • It will automatically execute tuareg-mode-hook when loaded, meaning any existing third-party packages or user configurations (like LSP, Merlin, etc.) hooked into tuareg-mode-hook will continue working seamlessly for .mli files.
  • It has its own major-mode value of 'tuareg-interface-mode and runs tuareg-interface-mode-hook.

Usage

In your emacs config:
(tuareg-use-interface-mode t)

@spwhitton

Copy link
Copy Markdown

@monnier do you possibly have any time to look at this? If not, if you are able to grant commit rights, perhaps you could give them to me so I can review and merge it? Thanks.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants