Skip to content

feat(lsp): add OCaml (ocamllsp) with beginner-friendly defaults - #19

Merged
hypatia-tile merged 2 commits into
mainfrom
feat/ocaml-lsp
Aug 4, 2026
Merged

feat(lsp): add OCaml (ocamllsp) with beginner-friendly defaults#19
hypatia-tile merged 2 commits into
mainfrom
feat/ocaml-lsp

Conversation

@hypatia-tile

Copy link
Copy Markdown
Owner

What

Add OCaml language support aimed at learning the language, wired through the Neovim 0.11+ native LSP API (same shape as nil/clangd).

Changes

  • after/lsp/ocamllsp.luaocamllsp config: cmd = { "ocamllsp" }, root markers (dune-project/dune-workspace/.git), and beginner-friendly settings:
    • inlay hints (let bindings + pattern variables), auto-enabled on attach via on_attach (other filetypes keep the global off default; <leader>lh still toggles).
    • extendedHover + syntaxDocumentation; codelens intentionally off (duplicates inlay hints).
  • after/ftplugin/ocaml.luavim.lsp.enable "ocamllsp".
  • lua/plugins/conform.luaocaml = { "ocamlformat" } on the existing format-on-save path (no-ops without .ocamlformat).
  • docs/adr/0001-ocaml-lsp-via-opam.md — first ADR: opam provisioning, native API, why not mason/Nix, deferred REPL.
  • CLAUDE.md — synced Architecture + format-on-save sections.

Out of repo (do separately)

opam install ocaml-lsp-server ocamlformat dune   # + utop later for a REPL

Put a .ocamlformat at the project root to enable format-on-save.

Deferred (per grilling)

  • utop REPL toggle, dune-file LSP attach, mason entry — easy follow-ups.

Verification

  • bin/check (lock-faithful restore): OK.
  • Headless: opening a .ml buffer resolves filetype=ocaml, the ocamllsp native config (cmd=ocamllsp, inlay settings present), and vim.lsp.enable runs without error. The server itself isn't present in CI, so it simply doesn't start — no load error.

🤖 Generated with Claude Code

hypatia-tile and others added 2 commits August 4, 2026 20:19
Wire ocaml-lsp-server through the native LSP API, matching the nil/clangd
pattern: after/lsp/ocamllsp.lua holds the config, after/ftplugin/ocaml.lua
enables it. The server is expected on PATH via opam (docs/adr/0001).

Beginner-friendly defaults for learning the language:
- inlay hints for let bindings and pattern variables, enabled
  automatically on attach (other filetypes keep the global off default).
- extendedHover and syntaxDocumentation for richer hover; codelens left
  off as it duplicates the inlay hints.

Formatting goes through Conform (ocaml = { "ocamlformat" }) on the existing
format-on-save path; ocamlformat no-ops without a .ocamlformat file.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Record the first ADR: provision OCaml tooling via opam and wire ocamllsp
through the native LSP API, rejecting mason (switch-agnostic build) and
Nix (poor fit for per-project switches). Update the Architecture and
format-on-save sections to mention ocamllsp and ocamlformat.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hypatia-tile
hypatia-tile merged commit f769434 into main Aug 4, 2026
3 checks passed
@hypatia-tile
hypatia-tile deleted the feat/ocaml-lsp branch August 4, 2026 11:26
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.

1 participant