We should always define the 2 flycheck initialization functions: Spacemacs will call them as needed only when enabling syntax checking. Previously flycheck wasn't getting activated at all. Only activate `flycheck-ocaml` when a `.merlin` file is present. It would work when there isn't but there is a high chance that you will get a lot of errors displayed because it could not find any of the used modules (`.merlin` specifies module paths). OCaml projects usually do have a `.merlin` file (either hand crafted or generated by the build system). Signed-off-by: Edwin Török <edwin@etorok.net> lang/ocaml: add merlin-eldoc and merlin-imenu support This displays the type and documentation of thing under point and highlights occurrences automatically when idle. Could be achieved by appropriate use of keyboard shortcuts already set up by this module. However `merlin-eldoc` can also display the expected type of function call parameters, which merlin itself wouldn't. `merlin-imenu` allows jumping to top level modules/functions/etc. bound by default to `SPC j i`. Signed-off-by: Edwin Török <edwin@etorok.net> lang/ocaml: add merlin-iedit multiple cursor refactoring bound to `, r e`. Signed-off-by: Edwin Török <edwin@etorok.net> fixup! lang/ocaml: add merlin-iedit multiple cursor refactoring fixup! lang/ocaml: fix flycheck-ocaml activation fixup! lang/ocaml: add merlin-eldoc and merlin-imenu support |
||
---|---|---|
.. | ||
img | ||
config.el | ||
funcs.el | ||
packages.el | ||
README.org |
Ocaml layer
Description
This is a very basic layer for editing ocaml files.
Features:
- Syntax highlighting (major-mode) via tuareg-mode
- Error reporting, completion and type display via merlin
- auto-completion with company mode via merlin
- syntax-checking via flycheck-ocaml (or alternatively merlin)
dune
file syntax highlighting and template insertion via dune-mode
Install
Layer
To use this configuration layer, add it to your ~/.spacemacs
. You will need to
add ocaml
to the existing dotspacemacs-configuration-layers
list in this
file.
Using merlin for error reporting
By default flycheck-ocaml is used for error reporting when the
syntax-checking
layer is also enabled as this is common throughout spacemacs.
You can disable this and switch back to merlin's default error reporting method
by adding flycheck-ocaml to your excluded packages list in .spacemacs
:
dotspacemacs-excluded-packages '(... flycheck-ocaml ... )
OPAM packages
This layer requires some opam packages:
merlin
for auto-completionutop
ocp-indent
To install them, use the following command:
opam install merlin utop ocp-indent
Make sure opam is initialized and configured.
opam init
opam config setup -a
Key bindings
Key binding | Description |
---|---|
SPC m = |
Indent buffer. |
SPC m c c |
Compile |
SPC m c p |
Check .merlin for errors |
SPC m c r |
Refresh changed .cmis in merlin |
SPC m e C |
Check for errors in current buffer |
SPC m e n |
Jump to next error |
SPC m e N |
Jump back to previous error |
SPC m g a |
Switch ML <-> MLI |
SPC m g b |
Go back to the last position where the user did a locate |
SPC m g g |
Locate the identifier under point (same window) |
SPC m g G |
Locate the identifier under point (different window) |
SPC m g i |
Prompt for module name and switch to ML file |
SPC m g I |
Prompt for module name and switch to MLI file |
SPC m g l |
Prompt for identifier and locate |
SPC m g o |
List occurrences for identifier under point |
SPC m h h |
Document the identifier under point |
SPC m h t |
Highlight identifier under cursor and print its type |
SPC m h T |
Prompt for expression and show its type |
SPC m r d |
Case analyze the current enclosing |
SPC m t p |
Dune run tests and promote. |
SPC m t P |
Dune promote. |
REPL (utop)
Key binding | Description |
---|---|
C-j |
(in REPL) next item in history |
C-k |
(in REPL) previous item in history |
SPC m s b |
Send buffer to the REPL |
SPC m s B |
Send buffer to the REPL and switch to the REPL in insert state |
SPC m s i |
Start a REPL |
SPC m s p |
Send phrase to the REPL |
SPC m s P |
Send phrase to the REPL and switch to the REPL in insert state |
SPC m s r |
Send region to the REPL |
SPC m s R |
Send region to the REPL and switch to the REPL in insert state |
Dune
Key binding | Description |
---|---|
SPC m c c |
Compile. |
SPC m i a |
Insert alias stanza. |
SPC m i c |
Insert copyfiles stanza. |
SPC m i d |
Insert ignored subdirs stanza. |
SPC m i e |
Insert executable stanza. |
SPC m i i |
Insert install stanza. |
SPC m i l |
Insert library stanza. |
SPC m i m |
Insert menhir stanza. |
SPC m i p |
Insert ocamllex stanza. |
SPC m i r |
Insert rule stanza. |
SPC m i t |
Insert tests stanza. |
SPC m i v |
Insert env stanza. |
SPC m i x |
Insert executables stanza. |
SPC m i y |
Insert ocamlyacc stanza. |
SPC m t p |
Dune run tests and promote. |
SPC m t P |
Dune promote. |
TODO layer improvements list
- Add more proper spacemacs key bindings for basic merlin tasks
- Add proper key bindings for ocamldebug
- Add more key bindings for tuareg-mode