menhir-lsp is a Language Server for the OCaml dialects Menhir and Ocamllex. Its goal is to provide first-class language support for their syntaxes in client editors. A client for VS Code is available through a VS Code extension.
- Find References
- Jump to Definition
- Hover
- Document Symbols
- Completion
- Code Actions
- Rename
- Selection Range
Install the server through opam:
opam install menhir-lsp
The server alone doesn't do much, to do its job it needs a client that talks the Language Server Protocol running in your editor. If you use VS Code proceed by installing the Menhir extension, then open a document with the .mly or .mll file extension. The LSP client will launch the server and communicate with it automatically.
For other editors, please refer to their documentation on how to register an LSP client.
Run these commands if you encounter a problem with the opam package or you'd like to hack on the server:
git clone https://github.com/dalps/menhir-lsp.git && cd menhir-lsp
dune install
You can also download a copy of the binary from the lateset release on GitHub. Put it under a folder that's included in your PATH and the client should be able to run it as well.
The server's code lives in the bin directory. It relies on Linol, an OCaml package that simplifies the development of Language Servers, and the visitors OCaml syntax plugin, for automating AST traversals.
It is also based on the original codebases of both Menhir and Ocamllex, whose parsers I modified in order to annotate their ASTs with source locations and make error recovery possible.
Additional references: ocaml-lsp, atd-lsp, catala-lsp. These were huge help material for implementing common LSP tasks in OCaml.
Currently only VS Code is supported, but not everyone uses VS Code. If you think this is useful and would like to have menhir-lsp work in your preferred editor, please consider contributing a new client / extension / adapter through a PR. I'm planning to maintain only the VS Code client since that it is my daily editor.
Issues for bugs / missing features are welcome.
GNU General Public License v2.0 only