2019-09-13 22:04:53 -04:00
|
|
|
#+TITLE: lang/ocaml
|
|
|
|
#+DATE: June 27, 2017
|
|
|
|
#+SINCE: v2.0.3
|
2018-09-21 00:06:12 +01:00
|
|
|
|
2019-09-13 22:04:53 -04:00
|
|
|
* Table of Contents :TOC:
|
|
|
|
- [[#description][Description]]
|
|
|
|
- [[#module-flags][Module Flags]]
|
|
|
|
- [[#plugins][Plugins]]
|
|
|
|
- [[#prerequisites][Prerequisites]]
|
|
|
|
- [[#features][Features]]
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#appendix][Appendix]]
|
|
|
|
- [[#commands][Commands]]
|
|
|
|
- [[#hacks][Hacks]]
|
2018-09-21 00:06:12 +01:00
|
|
|
|
2019-09-13 22:04:53 -04:00
|
|
|
* Description
|
|
|
|
This module adds [[https://ocaml.org/][OCaml]] support to Doom Emacs, powered by [[https://github.com/ocaml/tuareg][tuareg-mode]].
|
|
|
|
|
|
|
|
+ Code completion, documentation look-up, code navigation and refactoring
|
|
|
|
([[https://github.com/ocaml/merlin/wiki/emacs-from-scratch][merlin]])
|
2018-10-17 00:13:20 +01:00
|
|
|
+ Type, documentation and function argument display on idle ([[https://github.com/Khady/merlin-eldoc][merlin-eldoc]])
|
2018-09-21 00:06:12 +01:00
|
|
|
+ REPL ([[https://github.com/ocaml-community/utop][utop]])
|
|
|
|
+ Syntax-checking (~merlin~ with [[https://github.com/flycheck/flycheck-ocaml][flycheck-ocaml]])
|
|
|
|
+ Auto-indentation ([[https://github.com/OCamlPro/ocp-indent][ocp-indent]])
|
|
|
|
+ Code formatting ([[https://github.com/ocaml-ppx/ocamlformat][ocamlformat]])
|
|
|
|
+ Dune file format ([[http://dune.build/][dune]])
|
|
|
|
|
2019-09-13 22:04:53 -04:00
|
|
|
** Module Flags
|
|
|
|
This module provides no flags.
|
2018-09-21 00:06:12 +01:00
|
|
|
|
2019-09-13 22:04:53 -04:00
|
|
|
** Plugins
|
|
|
|
+ [[https://github.com/ocaml/tuareg][tuareg]]
|
|
|
|
+ [[https://github.com/ocaml/merlin][merlin]]
|
|
|
|
+ [[https://github.com/Khady/merlin-eldoc][merlin-eldoc]]
|
|
|
|
+ [[https://github.com/OCamlPro/ocp-indent][ocp-indent]]
|
|
|
|
+ [[https://github.com/flycheck/flycheck-ocaml][flycheck-ocaml]]*
|
|
|
|
+ [[https://github.com/ocaml-community/utop][utop]]*
|
|
|
|
+ [[https://github.com/ocaml-ppx/ocamlformat][ocamlformat]]*
|
|
|
|
+ [[https://github.com/ocaml/dune][dune]]
|
2018-09-21 00:06:12 +01:00
|
|
|
|
|
|
|
* Prerequisites
|
2019-09-13 22:04:53 -04:00
|
|
|
This module has no hard dependencies, but it is recommanded that you install
|
|
|
|
[[http://opam.ocaml.org/][opam]] and the following opam (optional) packages:
|
|
|
|
|
2018-09-21 00:06:12 +01:00
|
|
|
#+BEGIN_SRC shell
|
|
|
|
opam install merlin utop ocp-indent dune ocamlformat
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Features
|
2019-09-13 22:04:53 -04:00
|
|
|
+ The following files should have syntax highlighting support: ~.ml{i,p,y,}~,
|
|
|
|
~.eliom{i,}~, ~jbuild~, ~dune~, ~opam~
|
2018-09-21 00:06:12 +01:00
|
|
|
+ =merlin-mode= is activated whenever a =.merlin= file is found (including in a
|
|
|
|
parent directory) and =ocamlmerlin= executable is present
|
2019-09-13 22:04:53 -04:00
|
|
|
+ Line-based auto-indentation is provided by =ocp-indent=, if it is available.
|
2018-09-21 00:06:12 +01:00
|
|
|
|
|
|
|
* Configuration
|
2019-09-13 22:04:53 -04:00
|
|
|
+ If =:completion company= is enabled then autocomplete is provided by =merlin=
|
2020-01-14 03:04:26 -05:00
|
|
|
+ When =:checkers syntax= is enabled then =flycheck-ocaml= is activated to do
|
2019-02-22 00:20:29 -05:00
|
|
|
on-the-fly syntax/type checking via =merlin=, otherwise this is only done when
|
|
|
|
the file is saved.
|
2020-01-14 03:04:26 -05:00
|
|
|
+ Spell checking is activated in comments if =:checkers spell= is active
|
2019-09-13 22:04:53 -04:00
|
|
|
+ A REPL is provided if =utop= is installed and =:tools eval= is active
|
|
|
|
+ If =:editor format= is enabled, the =ocamlformat= executable is available and
|
2018-09-21 00:06:12 +01:00
|
|
|
there is an =.ocamlformat= file present then =format-all-buffer= is bound to
|
|
|
|
=ocamlformat=, otherwise to =ocp-indent=
|
2019-09-13 22:04:53 -04:00
|
|
|
+ If =:editor multiple-cursors= is enabled then identifiers can be refactored
|
2018-10-17 00:13:20 +01:00
|
|
|
with =v R= and multiple cursors (this correctly matches identifier occurrences
|
|
|
|
according to scope, it is not purely a textual match)
|
2019-09-13 22:04:53 -04:00
|
|
|
+ If =:emacs imenu= is enabled then top level symbols (modules, type, functions,
|
|
|
|
etc.) can be looked up using =SPC / i=
|
2018-09-21 00:06:12 +01:00
|
|
|
|
2020-02-19 23:34:16 -05:00
|
|
|
Run =doom sync= to install all packages and =doom doctor= to diagnose missing
|
|
|
|
tools.
|
2018-09-21 00:06:12 +01:00
|
|
|
|
|
|
|
* Appendix
|
|
|
|
** Commands
|
2019-09-13 22:04:53 -04:00
|
|
|
| Command | Key | Description |
|
|
|
|
|------------------------------+-----------+-----------------------------------------------------------|
|
|
|
|
| =merlin-type-enclosing= | =SPC m t= | display type under point |
|
|
|
|
| =tuareg-find-alternate-file= | =SPC m a= | switch between =.ml= and =.mli= |
|
|
|
|
| =merlin-locate= | =gd= | lookup definition |
|
|
|
|
| =merlin-occurences= | =SPC c D= | lookup references |
|
|
|
|
| =merlin-document= | =K= | lookup documentation |
|
|
|
|
| =merlin-imenu= | =SPC / i= | symbol lookup in file |
|
|
|
|
| =merlin-iedit-occurrences= | =v R= | visual refactor identifier under point (multiple cursors) |
|
|
|
|
| =utop= | =SPC o r= | open =utop= as REPL |
|
|
|
|
| =utop-eval-region= | =SPC c e= | evaluate selected region in =utop= |
|
2018-09-21 00:06:12 +01:00
|
|
|
|
|
|
|
** Hacks
|
|
|
|
+ =set-pretty-symbols!= is called with the full tuareg prettify symbol list, this
|
|
|
|
can cause columns to change as certain keywords are shortened (e.g. =fun=
|
|
|
|
becomes \lambda.
|
|
|
|
+ =tuareg-opam-update-env= is called the first time =tuareg= is loaded
|