init.el

February 24, 2017 ยท View on GitHub

;;---------------------------------------------------------------------------- ;; Reason setup ;; Expects reason-cli to be installed: ;; npm install -g git://github.com/reasonml/reason-cli.git ;;----------------------------------------------------------------------------

(defun chomp-end (str) "Chomp tailing whitespace from STR." (replace-regexp-in-string (rx (* (any " \t\n")) eos) "" str))

(defun real-path (path) "Resolves the actual path for PATH." (chomp-end (shell-command-to-string (concat "realpath " path))))

(let ((support-base-dir (concat (replace-regexp-in-string "refmt\n" "" (shell-command-to-string (concat "realpath " (shell-command-to-string "which refmt")))) "..")) (merlin-base-dir (concat (replace-regexp-in-string "ocamlmerlin\n" "" (shell-command-to-string (concat "realpath " (shell-command-to-string "which ocamlmerlin")))) ".."))) ;; Add npm merlin.el to the emacs load path and tell emacs where to find ocamlmerlin (add-to-list 'load-path (concat merlin-base-dir "/share/emacs/site-lisp/")) (setq merlin-command (concat merlin-base-dir "/bin/ocamlmerlin"))

;; Add npm reason-mode to the emacs load path and tell emacs where to find refmt (add-to-list 'load-path (concat support-base-dir "/share/emacs/site-lisp")) (setq refmt-command (concat support-base-dir "/bin/refmt")))

(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)

(require 'merlin-iedit) (defun evil-custom-merlin-iedit () (interactive) (if iedit-mode (iedit-mode) (merlin-iedit-occurrences))) (define-key merlin-mode-map (kbd "C-c C-e") 'evil-custom-merlin-iedit)