Last active
August 29, 2015 14:09
-
-
Save smondet/d9b09d713f0885002dfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-to-list 'sebs-packages 'tuareg) | |
(setq opam-share | |
(substring | |
(shell-command-to-string "opam config var share 2> /dev/null") 0 -1)) | |
(add-to-list 'load-path (concat opam-share "/emacs/site-lisp")) | |
(require 'merlin) | |
(setq ocp-indent-config "strict_with=always,with=0,strict_comments=false") | |
(require 'ocp-indent) | |
(add-to-list 'auto-mode-alist '("\\.eliom" . tuareg-mode)) | |
(add-to-list 'auto-mode-alist '("\\.atd" . tuareg-mode)) | |
(add-to-list 'magic-mode-alist '("#! */usr/bin/env *.*ocaml.*" . tuareg-mode)) | |
(add-hook 'tuareg-mode-hook | |
'(lambda () | |
(merlin-mode) | |
(add-to-list 'company-backends 'merlin-company-backend) | |
(ocp-setup-indent) | |
(define-with-leader-local "ss" 'tuareg-find-alternate-file) | |
(define-with-leader-local "t" 'merlin-type-enclosing) | |
(define-with-leader-local "l" 'merlin-locate) | |
(define-with-leader-local "d" 'merlin-destruct) | |
(define-with-leader-local "sm" 'merlin-switch-to-ml) | |
(define-with-leader-local "si" 'merlin-switch-to-mli) | |
(define-with-leader-local "fo" 'merlin-occurrences) | |
(define-with-leader-local "0" 'merlin-phrase-prev) | |
(define-with-leader-local "=" 'merlin-phrase-next) | |
(define-with-leader-local "en" 'merlin-error-prev) | |
(define-with-leader-local "ep" 'merlin-error-next) | |
(defunkey-local "ou" open-line-with-unit-monad | |
(progn | |
(move-end-of-line 1) | |
(newline-and-indent) | |
(insert ">>= fun () ->") | |
(indent-for-tab-command) | |
)) | |
(defunkey-local "om" open-line-with-any-monad | |
(progn | |
(move-end-of-line 1) | |
(newline-and-indent) | |
(insert ">>= fun ->") | |
(backward-char 3) | |
(indent-for-tab-command) | |
)) | |
(defunkey-local "op" open-line-with-pattern-match | |
(progn | |
(move-end-of-line 1) | |
(newline-and-indent) | |
(insert "| ->") | |
(backward-char 3) | |
(indent-for-tab-command) | |
)) | |
(defunkey-local "bmw" open-line-with-begin-match-with | |
(progn | |
(move-end-of-line 1) (newline-and-indent) | |
(insert "begin match with") | |
(move-end-of-line 1) (newline-and-indent) | |
(insert "| _") | |
(move-end-of-line 1) (newline-and-indent) | |
(insert "end") | |
(indent-for-tab-command) | |
(previous-line) | |
(evil-next-line-1-first-non-blank) | |
(forward-char 11) | |
)) | |
(defunkey-local ";" append-semicolon | |
(progn | |
(end-of-line) | |
(insert ";"))) | |
(defunkey-local "ai" append-in | |
(progn | |
(end-of-line) | |
(insert " in"))) | |
(defunkey-local "ro" run-ocaml-toplevel | |
(tuareg-run-ocaml)) | |
(evil-define-operator ocaml-eval-text-object (beg end type) | |
:move-point nil | |
(progn | |
(evil-exit-visual-state) | |
(let ((text (buffer-substring-no-properties beg end))) | |
(set-buffer tuareg-interactive-buffer-name) | |
(goto-char (point-max)) | |
(comint-send-string tuareg-interactive-buffer-name | |
(concat text ";;")) | |
(comint-send-input)))) | |
(define-with-leader-local "er" 'ocaml-eval-text-object) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment