A language server for OCaml and related languages
This is an implementation of the language server protocol for OCaml and related languages like BuckleScript and Reason.
See lsp-mode. Follow the installation
instructions there then add the following snippet(s) to your
~/.emacs.d/init.el
. You will need the tuareg
package installed and probably
other packages like flycheck
and company-mode
for most of the language
server features to work.
(lsp-define-stdio-client 'tuareg-mode "ocaml" 'stdio
#'(lambda () default-directory)
"OCaml Language Server"
'("ocaml-language-server" "--stdio"))
(add-hook 'tuareg-mode-hook #'lsp-mode)
(lsp-define-stdio-client 'reason-mode "reason" 'stdio
#'(lambda () default-directory)
"OCaml Language Server"
'("ocaml-language-server" "--stdio"))
(add-hook 'reason-mode-hook #'lsp-mode)
See vscode-reasonml. The OCaml Language Server comes bundled with this VS Code extension and no additional configuration steps are necessary.
Install Sublime Text LSP. For Reason support, see the instructions at sublime-reason.
For other editors, see the following list of language client packages. Note that the OCaml language server has not been tested extensively with other editors yet. If you try to use one of these packages and encounter a problem, please open an issue about it.
- OCaml support
- Reason support
- compiler diagnostics
- incremental document synchronization
- code action provider
- code lens provider
- completion provider
- definition provider
- document formatting provider (Reason)
- document highlight provider
- document range formatting provider (Reason)
- document symbol provider
- hover provider
- references provider
- workspace symbol provider
The server can be installed with npm:
npm install -g ocaml-language-server
The server can be launched in the following ways:
ocaml-language-server --node-ipc
ocaml-language-server --socket={number}
ocaml-language-server --stdio
For node-based clients like
vscode-reasonml --node-ipc
is the most efficient approach. Clients written in other languages should use
--stdio
or --socket
.
Execute the following steps:
yarn install
yarn run compile