The engine that powers OCaml and Reason's editors support!
This is an implementation of the language server protocol. It's a simple idea: every mainstream editor implements a language client, which receives your editor actions (autocompletion, jump-to-definition, show type, etc.) and calls a language server, which returns the asked information.
The insight is to standardize the way every editor queries the language server. This way, instead of reimplementing e.g. one Reason plugin for every single editor out there, we implement everything once inside our language server, and all editors that support language client receives the feature. Diagram here.
Every editor using this language-server should in theory have all the following features:
- 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
- BuckleScript build system integration (currently only activated for vscode)
npm install -g ocaml-language-server
The server relies on some external dependencies you have to install yourself. If you're a pure OCaml user:
- OCaml
4.02.3
or greater - merlin
2.5.0
or greater
If you're a Reason/BuckleScript user:
Install Reason + OCaml + Merlin through Reason's recommended installation or the alternative OPAM installation.
Pick your favorite editor and install the plugin! They should all work with ocaml-language-server. Some of them are called "myeditor-reason", but they support both Reason and OCaml.
-
Atom: atom-ide-reason
-
Emacs: lsp-ocaml. For extra Reason support: the emacs integration isn't using language-server/client yet. Please use reason instead.
-
Oni: see here.
-
VSCode: vscode-reasonml. The ocaml-language-server comes bundled with this VS Code extension; no additional configuration is necessary.
-
Sublime Text: Sublime Text LSP. For extra Reason support, see sublime-reason.
-
NeoVim/Vim 8 with Python 8: LanguageClient-neovim. For extra Reason support, see vim-reason-plus.
-
Other Editors: see the following list of language client packages. Note that ocaml-language-server hasn't 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.
Your editor's language-client should have a configuration to start the 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
.
Clone the repo and do:
yarn install # install dependencies
node ./bin/server --stdio # start the server