apm install linter-ocaml
This is a linter for OCaml using merlin for the actual linting. It builds on atom-linter, like many of the other linter packages. It also uses merlin to show types of expressions. More merlin functionality will hopefully be exposed as atom commands in the future.
Linting is performed when you save the file.
With hyperclick installed you can also cmd-click on a word to activate the
For the keymap some effort has been expended in picking key combinations that already seem to be used for similar things in other contexts (e.g. the symbols-view package).
Keyboard activated commands:
|Command||Description||Keybinding (Linux)||Keybinding (OS X)|
||Show type of expression at cursor||ctrl-alt-?||cmd-alt-?|
||Show type of expression one level up||ctrl-alt-.||cmd-alt-.|
||Show type of expression one level down||ctrl-alt-,||cmd-alt-,|
||Jump to the symbol at the cursor||ctrl-alt-down||cmd-alt-down|
||Return from the jump||ctrl-alt-up||cmd-alt-up|
I’ve now used this myself for some time on a program of a couple of thousand LOC, and it seems to work well. However it still has only been tested on fairly small programs so YMMV. Bug reports are welcomed.
You should ensure that you are on the latest released merlin version.
Tested on OS X and Linux. Not tested at all on Windows, but if you can get merlin to work I suppose it should work.
Other packages you probably want:
- language-ocaml to get syntax highlighting.
- minimap to see errors/warnings in a nice minimappy thing.
- hyperclick to get clicky functionality (cmd-click on symbols).
The package itself can be installed the normal way (from the Atom package installer).
It depends on
ocamlmerlin being in
PATH. The simple way to do this is
to install opam and then install merlin:
opam install merlin
Additionally you must have a working merlin setup for you project. IOW you must
.merlin file in your project root directory.
If you are an experienced OCaml person you may stop reading now (or continue reading and then report any mistakes or bad advice).
I’m not experienced in OCaml so YMMV, however my projects are set up as follows.
.merlin file which looks something like this (add all the packages you need):
I then have a small build script:
ocamlbuild -package core_extended -I src yo.byte
The above assumes you have your sources in
src (and your main program is
yo.ml). The globbing in
.merlin is needed because
_build and merlin needs to see all the cmi files to
find symbols and whatnot.
I recommend also installing ocp-indent (also using opam) and run this on source files before compilation. Personally I have a simple makefile that runs it before running ocamlbuild. Atom refreshes the indented files automatically.