Skip to content

feat(editor): add OCaml and MLX syntax highlighting - #16421

Closed
rusty-key wants to merge 2 commits into
stablyai:mainfrom
rusty-key:feat/ocaml-syntax-highlighting
Closed

rusty-key wants to merge 2 commits into
stablyai:mainfrom
rusty-key:feat/ocaml-syntax-highlighting

Conversation

@rusty-key

@rusty-key rusty-key commented Aug 25, 2026 •

Copy link
Copy Markdown

ELI5

Orca's editor treats OCaml (.ml, .mli, .ocamlinit) and MLX (.mlx, OCaml with JSX) files as plain text. This adds syntax highlighting for both.

What Changed

  • Registered ocaml and ocaml.mlx as Monaco languages, backed by TextMate grammars vendored from ocamllabs/vscode-ocaml-platform (ISC license).
  • .ml/.mli/.ocamlinit map to ocaml; .mlx gets its own language id and grammar because MLX's grammar is a superset of OCaml's rather than an include of it.
  • Added file-type icons for .ml/.mli/.mlx/.ocamlinit.

Why

OCaml and MLX files currently render with no highlighting, unlike every other mainstream language Orca supports.

Linked Issue

Fixes #16416

Visual Proof

Before:
CleanShot 2026-08-25 at 09 49 50@2x

After:
CleanShot 2026-08-25 at 09 48 06@2x

Testing

  • Automated tests added/updated
    • Fixture-driven TextMate tokenization tests for both grammars (nested comments, quoted string literals, type variables vs. character literals, JSX tags vs. comparison operators), asserting editor-like state carried across lines.
    • detectLanguage coverage for the new extensions and the .ocamlinit exact-name case.
  • I manually tested these changes locally

Platform tested: macOS. The change is UI-only (Monaco language registration + static data tables) with no OS-specific code path, so I did not test Linux/Windows/SSH separately.

pnpm lint, pnpm typecheck pass. pnpm test: no failures in any file this PR touches; the full suite currently has pre-existing failures unrelated to this change (git-binary integration tests, fish-shell/node-pty tests, macOS keychain tests, electron-vite dev server tests) that reproduce identically on main without these commits.

AI Disclosure

Implementation, tests, and this description were done with Claude Code (Claude Opus 5), with review and direction from me throughout.

Review

Agent skill upstream boundary

  • Not applicable — this change does not touch skill installation, discovery, or sharing.

Notes

UI-only change (Monaco language registration, static extension/icon tables). No SSH, mobile, or backwards-compatibility surface; no hot-path or startup cost — grammars load lazily on first .ml/.mlx open, confirmed via existing build output (they land in their own async chunk, not the renderer entry).

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

rusty-key and others added 2 commits August 24, 2026 17:58
Register `ocaml` as a TextMate-backed Monaco language covering `.ml`,
`.mli` and `.ocamlinit`, using the vendored ocamllabs/vscode-ocaml-platform
grammars (ISC).

`.mli` shares the `.ml` language id: `source.ocaml#bindings` includes
`source.ocaml.interface#bindings`, so one registration covers both.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Register `ocaml.mlx` for `.mlx` files using the vendored MLX grammar from
the same ocamllabs/vscode-ocaml-platform release. MLX is OCaml with JSX
expressions, and its grammar is a superset of the OCaml rules rather than
an include of them, so it needs its own scope; the language configuration
is shared with OCaml, matching upstream.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 24fe1b61-dac7-4273-9e67-a55c4fef41ff

📥 Commits

Reviewing files that changed from the base of the PR and between 8217e68 and 09c303d.

📒 Files selected for processing (16)
  • src/renderer/src/lib/file-type-icon-extension-table.ts
  • src/renderer/src/lib/file-type-icon-name-table.ts
  • src/renderer/src/lib/language-detect.test.ts
  • src/renderer/src/lib/language-detect.ts
  • src/renderer/src/lib/monaco-languages/__fixtures__/ocaml-mlx-syntax-traps.mlx
  • src/renderer/src/lib/monaco-languages/__fixtures__/ocaml-signature-traps.mli
  • src/renderer/src/lib/monaco-languages/__fixtures__/ocaml-syntax-traps.ml
  • src/renderer/src/lib/monaco-languages/register-ocaml.test.ts
  • src/renderer/src/lib/monaco-languages/register-ocaml.ts
  • src/renderer/src/lib/monaco-languages/textmate-fixture-tokenizer.ts
  • src/renderer/src/lib/monaco-languages/textmate-grammars/ocaml-LICENSE.txt
  • src/renderer/src/lib/monaco-languages/textmate-grammars/ocaml-interface.tmLanguage.json
  • src/renderer/src/lib/monaco-languages/textmate-grammars/ocaml-mlx.tmLanguage.json
  • src/renderer/src/lib/monaco-languages/textmate-grammars/ocaml.tmLanguage.json
  • src/renderer/src/lib/monaco-languages/textmate-token-provider.test.ts
  • src/renderer/src/lib/monaco-setup.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds OCaml and OCaml MLX language detection and file icons. It adds TextMate grammars for implementation, interface, and MLX syntax. It registers both languages with Monaco and loads grammars by scope. It adds shared tokenization utilities and fixtures for OCaml syntax, signatures, and JSX expressions. Tests cover registration, grammar loading, token scopes, state cleanup, language detection, and shared Oniguruma loading.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 9 files. (7 skipped: 7… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #16416 by registering OCaml and MLX Monaco languages, mapping the requested file types including .ocamlinit, adding TextMate grammars, and covering language detection and t…
Out of Scope Changes check ✅ Passed The changes remain within scope for issue #16416. Grammar files, Monaco registration, file mappings, icons, fixtures, and tests directly support OCaml and MLX syntax highlighting.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding OCaml and MLX syntax highlighting in the editor.
Description check ✅ Passed The description follows the required template and explains the change, rationale, linked issue, visual proof, testing, AI disclosure, compatibility considerations, and checklist status. It also explai…
Full details: Linked Issues check

Explanation

The changes satisfy issue #16416 by registering OCaml and MLX Monaco languages, mapping the requested file types including .ocamlinit, adding TextMate grammars, and covering language detection and tokenization with tests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 9 files. (7 skipped: 7 unsupported.)

Full details: Description check

Explanation

The description follows the required template and explains the change, rationale, linked issue, visual proof, testing, AI disclosure, compatibility considerations, and checklist status. It also explains why manual testing was not performed on other platforms.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor

Thank you @rusty-key for this! We've shipped OCaml and MLX as the official OCaml Syntax plugin instead of building it into Orca, so it can be updated on its own. It uses the same OCaml Platform grammars. Your work is credited: you're a co-author of the plugin commit.

To install: Settings → Plugins → turn on plugins → search for it and install. It needs Orca 1.4.246 or newer (older versions show "Needs Orca 1.4.246"), because that's the first release where an enabled plugin syntax takes precedence over Orca's own mapping for these files.

Closing this PR as superseded. If it falls short for you, please reopen and tell us what is missing.

@nwparker nwparker closed this Oct 30, 2026
senadaruc pushed a commit to senadaruc/orca-plugins that referenced this pull request Oct 31, 2026
Highlights .ml, .mli and .mlx files, with ocamldoc comments, using the
OCaml Platform's TextMate grammars (ISC). Needs Orca 1.4.246, the first
release where an enabled plugin syntax beats Orca's F# mapping for .ml/.mli.

Replaces stablyai/orca#16421 for stablyai/orca#16416.

Co-authored-by: Rusty.Key <[email protected]>
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.

[Feature]: Support syntax highlighting for OCaml (.ml/.mli/.mlx)

2 participants