ocaml: basic REPL(utop) and merlin key bindings
This commit is contained in:
parent
9b598b1d72
commit
1ec4ce2282
|
@ -9,6 +9,8 @@
|
|||
- [Description](#description)
|
||||
- [Install](#install)
|
||||
- [OPAM packages](#opam-packages)
|
||||
- [Key Bindings](#key-bindings)
|
||||
- [REPL (utop)](#repl-utop)
|
||||
- [TODO](#todo)
|
||||
|
||||
<!-- markdown-toc end -->
|
||||
|
@ -40,8 +42,29 @@ To install them, use the following command:
|
|||
opam install merlin
|
||||
```
|
||||
|
||||
## Key Bindings
|
||||
|
||||
Key Binding | Description
|
||||
----------------------|--------------------------------------------------------
|
||||
<kbd>SPC m c c</kbd> | Compile
|
||||
<kbd>SPC m e t</kbd> | Highlight identifier under cursor and print its type
|
||||
|
||||
### REPL (utop)
|
||||
|
||||
Key Binding | Description
|
||||
----------------------|--------------------------------------------------------
|
||||
<kbd>SPC m s b</kbd> | Send buffer to the REPL
|
||||
<kbd>SPC m s B</kbd> | Send buffer to the REPL and switch to the REPL in `insert state`
|
||||
<kbd>SPC m s i</kbd> | Start a REPL
|
||||
<kbd>SPC m s p</kbd> | Send phrase to the REPL
|
||||
<kbd>SPC m s P</kbd> | Send phrase to the REPL and switch to the REPL in `insert state`
|
||||
<kbd>SPC m s r</kbd> | Send region to the REPL
|
||||
<kbd>SPC m s R</kbd> | Send region to the REPL and switch to the REPL in `insert state`
|
||||
<kbd>C-j</kbd> | next item in history
|
||||
<kbd>C-k</kbd> | 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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue