lang/ocaml: major refactor

+ Load flyspell-mode a little later, to allow file/dir-local variables
  to customize flyspell.
+ Ensure setters (in merlin's config) are used as late as possible, by
  making merlin's (and all the other packages) config run after tuareg
  is loaded.
+ As discussed, installing packages locally is a bit unreliable, so I'm
  commenting out the +ocaml-site-lisp flag, and rely solely on packages
  from MELPA.
+ Add optional ocamlformat check in doctor.el and conditionally load the
  ocamlformat package (if editor/format is enabled).
+ Add docstrings to init hooks.
This commit is contained in:
Henrik Lissner 2018-10-16 02:45:12 -04:00
parent 4e81605463
commit d1d9cffcc8
3 changed files with 103 additions and 89 deletions

View file

@ -1,30 +1,32 @@
;; -*- no-byte-compile: t; -*-
;;; lang/ocaml/packages.el
(when (featurep! +opam-site-lisp)
(defvar +ocaml-elisp-dir
(when (executable-find "opam")
(let ((opam-share (ignore-errors (car (process-lines "opam" "config" "var" "share" "--safe")))))
(when (and opam-share (file-directory-p opam-share))
(expand-file-name "emacs/site-lisp" opam-share)))))
(defmacro localpackage! (name)
`(package! ,name :recipe (:fetcher file :path ,+ocaml-elisp-dir)))
(localpackage! opam-site-lisp))
(package! tuareg)
(package! merlin)
(package! ocp-indent)
(when (featurep! :feature syntax-checker)
(package! flycheck-ocaml))
(unless (featurep! +opam-site-lisp)
(package! merlin)
(package! ocp-indent)
(when (featurep! :feature eval)
(package! utop))
(when (featurep! :editor format)
;; by default quelpa generated a version 0pre0.20180929.192844, which got parsed into (0 -1 0 ...), which when compared with version nil (0)
;; in package-installed-p always yielded false
(package! ocamlformat :recipe (:fetcher github :repo "ocaml-ppx/ocamlformat" :files ("emacs/*.el"))))
(package! dune :recipe (:fetcher github :repo "ocaml/dune" :files ("editor-integration/emacs/*.el"))))
(when (featurep! :feature eval)
(package! utop))
(when (featurep! :editor format)
;; by default quelpa generated a version 0pre0.20180929.192844, which got
;; parsed into (0 -1 0 ...), which when compared with version nil (0) in
;; package-installed-p always yielded false
(package! ocamlformat :recipe (:fetcher github :repo "ocaml-ppx/ocamlformat" :files ("emacs/*.el"))))
(package! dune :recipe (:fetcher github :repo "ocaml/dune" :files ("editor-integration/emacs/*.el")))
;; (defvar +ocaml-elisp-dir
;; (when (executable-find "opam")
;; (let ((opam-share (ignore-errors (car (process-lines "opam" "config" "var" "share" "--safe")))))
;; (when (and opam-share (file-directory-p opam-share))
;; (expand-file-name "emacs/site-lisp" opam-share)))))
;;
;; (defmacro localpackage! (name)
;; `(package! ,name :recipe (:fetcher file :path ,+ocaml-elisp-dir)))
;;
;; (localpackage! opam-site-lisp)