2015-02-07 17:37:53 +00:00
|
|
|
;;; packages.el --- ocaml Layer packages File for Spacemacs
|
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq ocaml-packages
|
2015-02-07 17:37:53 +00:00
|
|
|
'(
|
2015-05-22 18:41:48 +00:00
|
|
|
;; auto-complete
|
2015-04-18 16:22:34 +00:00
|
|
|
company
|
2015-05-22 18:38:15 +00:00
|
|
|
;; flycheck
|
|
|
|
;; flycheck-ocaml
|
2015-05-12 03:45:26 +00:00
|
|
|
merlin
|
|
|
|
ocp-indent
|
|
|
|
tuareg
|
|
|
|
utop
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2015-02-07 17:37:53 +00:00
|
|
|
|
2015-05-24 18:56:33 +00:00
|
|
|
;;(defun ocaml/post-init-auto-complete ()
|
|
|
|
;; (spacemacs|enable-auto-complete merlin-mode))
|
2015-05-22 18:41:48 +00:00
|
|
|
|
2015-05-12 03:45:26 +00:00
|
|
|
(defun ocaml/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook merlin-mode))
|
2015-02-07 17:37:53 +00:00
|
|
|
|
2015-05-12 03:45:26 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'syntax-checking)
|
2015-05-22 18:38:15 +00:00
|
|
|
(defun ocaml/post-init-flycheck ()
|
2015-08-28 11:02:20 +00:00
|
|
|
(spacemacs/add-flycheck-hook 'merlin-mode))
|
2015-05-12 03:45:26 +00:00
|
|
|
(defun ocaml/init-flycheck-ocaml ()
|
|
|
|
(use-package flycheck-ocaml
|
|
|
|
:if (configuration-layer/package-usedp 'flycheck)
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
2015-05-22 18:38:15 +00:00
|
|
|
(with-eval-after-load 'merlin
|
2015-09-29 05:07:57 +00:00
|
|
|
(setq merlin-error-after-save nil)
|
|
|
|
(flycheck-ocaml-setup))
|
|
|
|
))))
|
2015-04-18 16:22:03 +00:00
|
|
|
|
2015-05-12 03:45:26 +00:00
|
|
|
(defun ocaml/init-merlin ()
|
|
|
|
(use-package merlin
|
|
|
|
:defer t
|
2015-04-18 16:22:03 +00:00
|
|
|
:init
|
2015-05-12 03:45:26 +00:00
|
|
|
(progn
|
|
|
|
(add-hook 'tuareg-mode-hook 'merlin-mode)
|
2015-05-24 18:56:33 +00:00
|
|
|
;; (set-default 'merlin-use-auto-complete-mode t)
|
|
|
|
(set-default 'merlin-use-auto-complete-mode nil)
|
2015-05-22 18:24:44 +00:00
|
|
|
(setq merlin-completion-with-doc t)
|
2015-05-12 03:45:26 +00:00
|
|
|
(push 'merlin-company-backend company-backends-merlin-mode)
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'tuareg-mode
|
|
|
|
"cp" 'merlin-project-check
|
|
|
|
"cr" 'merlin-refresh
|
|
|
|
"cv" 'merlin-goto-project-file
|
|
|
|
"eC" 'merlin-error-check
|
|
|
|
"en" 'merlin-error-next
|
|
|
|
"eN" 'merlin-error-prev
|
|
|
|
"gb" 'merlin-pop-stack
|
|
|
|
"gg" #'(lambda ()
|
2015-05-22 18:24:44 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((merlin-locate-in-new-window 'never))
|
|
|
|
(merlin-locate)))
|
2015-11-18 00:38:05 +00:00
|
|
|
"gG" #'(lambda ()
|
2015-05-22 18:24:44 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((merlin-locate-in-new-window 'always))
|
|
|
|
(merlin-locate)))
|
2015-11-18 00:38:05 +00:00
|
|
|
"gl" 'merlin-locate-ident
|
|
|
|
"gi" 'merlin-switch-to-ml
|
|
|
|
"gI" 'merlin-switch-to-mli
|
|
|
|
"hh" 'merlin-document
|
|
|
|
"ht" 'merlin-type-enclosing
|
|
|
|
"hT" 'merlin-type-expr
|
|
|
|
"rd" 'merlin-destruct
|
2015-05-12 03:45:26 +00:00
|
|
|
))))
|
2015-04-03 21:35:33 +00:00
|
|
|
|
2015-04-18 16:22:03 +00:00
|
|
|
(defun ocaml/init-ocp-indent ()
|
|
|
|
(use-package ocp-indent
|
2015-05-12 03:45:26 +00:00
|
|
|
:defer t
|
2015-04-18 16:22:03 +00:00
|
|
|
:init
|
2015-05-12 03:45:26 +00:00
|
|
|
(add-hook 'tuareg-mode-hook 'ocp-indent-caml-mode-setup)))
|
2015-04-18 16:22:03 +00:00
|
|
|
|
2015-05-12 03:45:26 +00:00
|
|
|
(defun ocaml/init-tuareg ()
|
|
|
|
(use-package tuareg
|
2015-04-18 16:22:34 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
2015-05-12 03:45:26 +00:00
|
|
|
(progn
|
|
|
|
(spacemacs//init-ocaml-opam)
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'tuareg-mode
|
|
|
|
"ga" 'tuareg-find-alternate-file
|
|
|
|
"cc" 'compile)
|
2015-11-02 18:09:47 +00:00
|
|
|
;; Make OCaml-generated files invisible to filename completion
|
|
|
|
(dolist (ext '(".cmo" ".cmx" ".cma" ".cmxa" ".cmi" ".cmxs" ".cmt" ".annot"))
|
|
|
|
(add-to-list 'completion-ignored-extensions ext)))
|
2015-05-12 03:45:26 +00:00
|
|
|
:config
|
|
|
|
(when (fboundp 'sp-local-pair)
|
2015-06-02 16:37:34 +00:00
|
|
|
;; don't auto-close apostrophes (type 'a = foo) and backticks (`Foo)
|
|
|
|
(sp-local-pair 'tuareg-mode "'" nil :actions nil)
|
|
|
|
(sp-local-pair 'tuareg-mode "`" nil :actions nil))))
|
2015-04-18 16:22:34 +00:00
|
|
|
|
2015-05-12 03:45:26 +00:00
|
|
|
(defun ocaml/init-utop ()
|
|
|
|
(use-package utop
|
|
|
|
:defer t
|
|
|
|
:init (add-hook 'tuareg-mode-hook 'utop-minor-mode)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; Setup environment variables using opam
|
|
|
|
(if (executable-find "opam")
|
|
|
|
(let ((vars (car (read-from-string
|
|
|
|
(shell-command-to-string "opam config env --sexp")))))
|
|
|
|
(dolist (var vars)
|
|
|
|
(setenv (car var) (cadr var))))
|
|
|
|
(spacemacs-buffer/warning "Cannot find \"opam\" executable."))
|
|
|
|
;; Update the emacs path
|
|
|
|
(setq exec-path (append (parse-colon-path (getenv "PATH"))
|
|
|
|
(list exec-directory)))
|
2015-04-18 16:22:34 +00:00
|
|
|
|
2015-05-12 03:45:26 +00:00
|
|
|
(defun spacemacs/utop-eval-phrase-and-go ()
|
|
|
|
"Send phrase to REPL and evaluate it and switch to the REPL in
|
|
|
|
`insert state'"
|
|
|
|
(interactive)
|
|
|
|
(utop-eval-phrase)
|
|
|
|
(utop)
|
|
|
|
(evil-insert-state))
|
2015-02-07 17:37:53 +00:00
|
|
|
|
2015-05-12 05:35:23 +00:00
|
|
|
(defun spacemacs/utop-eval-buffer-and-go ()
|
2015-05-12 03:45:26 +00:00
|
|
|
"Send buffer to REPL and evaluate it and switch to the REPL in
|
|
|
|
`insert state'"
|
|
|
|
(interactive)
|
|
|
|
(utop-eval-buffer)
|
|
|
|
(utop)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
|
|
|
(defun spacemacs/utop-eval-region-and-go (start end)
|
|
|
|
"Send region to REPL and evaluate it and switch to the REPL in
|
|
|
|
`insert state'"
|
|
|
|
(interactive "r")
|
|
|
|
(utop-eval-region start end)
|
|
|
|
(utop)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'tuareg-mode
|
|
|
|
"sb" 'utop-eval-buffer
|
|
|
|
"sB" 'spacemacs/utop-eval-buffer-and-go
|
|
|
|
"si" 'utop
|
|
|
|
"sp" 'utop-eval-phrase
|
|
|
|
"sP" 'spacemacs/utop-eval-phrase-and-go
|
|
|
|
"sr" 'utop-eval-region
|
|
|
|
"sR" 'spacemacs/utop-eval-region-and-go))
|
2015-05-12 03:45:26 +00:00
|
|
|
(define-key utop-mode-map (kbd "C-j") 'utop-history-goto-next)
|
|
|
|
(define-key utop-mode-map (kbd "C-k") 'utop-history-goto-prev)))
|