Last active
February 17, 2016 08:48
-
-
Save zbroyar/76b3810d0141b8970c30 to your computer and use it in GitHub Desktop.
OCaml editing mode, require ocp-indent to work properly
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
;; | |
;; OCaml mode | |
;; | |
(setq | |
opam-share | |
(substring | |
(shell-command-to-string "opam config var share 2>/dev/null") 0 -1)) | |
(setq load-path | |
(append (list (concat opam-share "/emacs/site-lisp")) load-path)) | |
(require 'merlin) | |
(require 'ocp-indent) | |
(setq merlin-command 'opam) | |
(setq merlin-use-auto-complete-mode 'easy) | |
(autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code." t) | |
(autoload 'ocamldebug "ocamldebug" "Run the OCaml debugger" t) | |
(add-to-list 'auto-mode-alist '("\\.ml[iylp]?" . tuareg-mode)) | |
(add-to-list 'auto-mode-alist '("\\.atd$" . tuareg-mode)) | |
(autoload 'tuareg-imenu-set-imenu "tuareg-imenu" "Configuration of imenu for tuareg" t) | |
(dolist (ext '(".cmo" ".cmx" ".cma" ".cmxa" ".cmi")) | |
(add-to-list 'completion-ignored-extensions ext)) | |
(add-hook | |
'tuareg-mode-hook | |
(lambda () | |
(abbrev-mode) | |
(merlin-mode) | |
(setq tab-width 2) | |
(setq indent-tabs-mode t) | |
(setq tab-always-indent nil) | |
(setq hs-hide-comments-when-hiding-all nil) | |
(tuareg-imenu-set-imenu) | |
(define-key tuareg-mode-map "\C-x\C-r" 'replace-regexp) | |
(define-key tuareg-mode-map [(control down)] 'tuareg-next-phrase) | |
(define-key tuareg-mode-map [(control up)] 'tuareg-previous-phrase) | |
(define-key tuareg-mode-map [(meta down)] 'tuareg-next-phrase) | |
(define-key tuareg-mode-map [(meta up)] 'tuareg-previous-phrase) | |
(when (require 'hideshow nil t) | |
(unless (assq 'tuareg-mode hs-special-modes-alist) | |
(add-to-list | |
'hs-special-modes-alist | |
`(tuareg-mode | |
,(concat "^" tuareg-definitions-regexp) | |
,tuareg-semicolon-match-stop-regexp | |
nil ;; nil means to use `comment-start' | |
(lambda (_arg) | |
(tuareg-next-phrase t nil) | |
(tuareg-skip-back-blank-and-comments)) | |
nil)))) | |
(when (featurep 'hideshow) | |
(hs-minor-mode 1) | |
(require 'fold-dwim)) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment