Created
December 29, 2017 22:03
-
-
Save gladimdim/6b98dbb13341df6866d6d7b1f303cd94 to your computer and use it in GitHub Desktop.
Emacs file for ReasonML setup
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
(require 'package) | |
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) | |
(not (gnutls-available-p)))) | |
(url (concat (if no-ssl "http" "https") "://melpa.org/packages/"))) | |
(add-to-list 'package-archives (cons "melpa" url) t)) | |
(when (< emacs-major-version 24) | |
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) | |
(package-initialize) | |
;; ## added by OPAM user-setup for emacs / base ## 56ab50dc8996d2bb95e7856a6eddb17b ## you can edit, but keep this line | |
(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el") | |
;; ## end of OPAM user-setup addition for emacs / base ## keep this line | |
;;---------------------------------------------------------------------------- | |
;; Reason setup | |
;;---------------------------------------------------------------------------- | |
(defun shell-cmd (cmd) | |
"Returns the stdout output of a shell command or nil if the command returned | |
an error" | |
(car (ignore-errors (apply 'process-lines (split-string cmd))))) | |
(let* ((refmt-bin (or (shell-cmd "which refmt"))) | |
(merlin-bin (or (shell-cmd "which ocamlmerlin"))) | |
(merlin-base-dir (when merlin-bin | |
(replace-regexp-in-string "bin/ocamlmerlin$" "" merlin-bin)))) | |
;; Add npm merlin.el to the emacs load path and tell emacs where to find ocamlmerlin | |
(when merlin-bin | |
(add-to-list 'load-path (concat merlin-base-dir "share/emacs/site-lisp/")) | |
(setq merlin-command merlin-bin)) | |
(when refmt-bin | |
(setq refmt-command refmt-bin))) | |
(require 'reason-mode) | |
(require 'merlin) | |
(add-hook 'reason-mode-hook (lambda () | |
(add-hook 'before-save-hook 'refmt-before-save) | |
(merlin-mode))) | |
(setq merlin-ac-setup t) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment