Skip to content

Instantly share code, notes, and snippets.

@sgrove

sgrove/init.el Secret

Last active February 24, 2017 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgrove/c9bdfed77f4da8db108dfb2c188f7baf to your computer and use it in GitHub Desktop.
Save sgrove/c9bdfed77f4da8db108dfb2c188f7baf to your computer and use it in GitHub Desktop.
;;----------------------------------------------------------------------------
;; 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment