diff --git a/contrib/lang/ocaml/README.md b/contrib/lang/ocaml/README.md
index 1f286280a..5266b11a4 100644
--- a/contrib/lang/ocaml/README.md
+++ b/contrib/lang/ocaml/README.md
@@ -9,6 +9,8 @@
- [Description](#description)
- [Install](#install)
- [OPAM packages](#opam-packages)
+ - [Key Bindings](#key-bindings)
+ - [REPL (utop)](#repl-utop)
- [TODO](#todo)
@@ -40,8 +42,29 @@ To install them, use the following command:
opam install merlin
```
+## Key Bindings
+
+ Key Binding | Description
+----------------------|--------------------------------------------------------
+SPC m c c | Compile
+SPC m e t | Highlight identifier under cursor and print its type
+
+### REPL (utop)
+
+ Key Binding | Description
+----------------------|--------------------------------------------------------
+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`
+C-j | next item in history
+C-k | previous item in history
+
## TODO
-- Add support for `flycheck` (using `flycheck-ocaml`)
-- Add proper spacemacs key-bindings for basic merlin tasks
-
+- Add more proper spacemacs key-bindings for basic merlin tasks
+- Add proper keybindings for ocamldebug
+- Add more keybindings for tuareg-mode
diff --git a/contrib/lang/ocaml/packages.el b/contrib/lang/ocaml/packages.el
index e0e992206..c6ff0de18 100644
--- a/contrib/lang/ocaml/packages.el
+++ b/contrib/lang/ocaml/packages.el
@@ -24,6 +24,9 @@
(defun ocaml/init-tuareg ()
(add-hook 'tuareg-mode-hook #'merlin-mode)
+ (evil-leader/set-key-for-mode 'tuareg-mode
+ "mcc" 'compile
+ )
)
(defun ocaml/opam ()
@@ -44,7 +47,30 @@
;; Update the emacs path
(setq exec-path (append (parse-colon-path (getenv "PATH"))
(list exec-directory)))
+ (defun utop-eval-phrase-and-go ()
+ (interactive)
+ (utop-eval-phrase)
+ (utop))
+ (defun utop-eval-buffer-and-go ()
+ (interactive)
+ (utop-eval-buffer)
+ (utop))
+ (defun utop-eval-region-and-go (start end)
+ (interactive "r")
+ (utop-eval-region start end)
+ (utop))
+ (evil-leader/set-key-for-mode 'tuareg-mode
+ "msb" 'utop-eval-buffer
+ "msB" 'utop-eval-buffer-and-go
+ "msi" 'utop
+ "msp" 'utop-eval-phrase
+ "msP" 'utop-eval-phrase-and-go
+ "msr" 'utop-eval-region
+ "msR" 'utop-eval-region-and-go
+ )
)
+ (define-key utop-mode-map (kbd "C-j") 'utop-history-goto-next)
+ (define-key utop-mode-map (kbd "C-k") 'utop-history-goto-prev)
)
(defun ocaml/init-ocp-indent ()
@@ -64,6 +90,11 @@
(when (configuration-layer/package-usedp 'company)
(push 'merlin-company-backend company-backends-merlin-mode))
)
+ (evil-leader/set-key-for-mode 'tuareg-mode
+ "mgg" 'merlin-locate
+ "met" 'merlin-type-enclosing
+ ;; "mhh" 'merlin-document
+ )
)
(when (configuration-layer/layer-usedp 'auto-completion)