Skip to content

Instantly share code, notes, and snippets.

@joefiorini
Created April 3, 2017 01:49
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 joefiorini/0204b4dd72a6722f57c84ed071f49929 to your computer and use it in GitHub Desktop.
Save joefiorini/0204b4dd72a6722f57c84ed071f49929 to your computer and use it in GitHub Desktop.
Spacemacs reason-mode layer
(spacemacs|define-jump-handlers reason-mode)
(defun spacemacs/merlin-locate ()
(interactive)
(let ((merlin-locate-in-new-window 'never))
(merlin-locate)))
(defun spacemacs/merlin-locate-other-window ()
(interactive)
(let ((merlin-locate-in-new-window 'always))
(merlin-locate)))
(setq jf-reason-packages
'(
company
ggtags
helm-gtags
merlin
(reason-mode
:location (recipe
:repo "facebook/reason"
:fetcher github
:files ("editorSupport/emacs/reason-mode.el" "editorSupport/emacs/refmt.el")))
))
(defun jf-reason/post-init-company ()
(when (configuration-layer/layer-usedp 'merlin)
(spacemacs|add-company-backends
:backends merlin-company-backend
:modes merlin-mode
:variables merlin-completion-with-doc t)))
(when (configuration-layer/layer-usedp 'syntax-checking)
(defun jf-reason/post-init-flycheck ()
(spacemacs/enable-flycheck 'merlin-mode)))
(defun jf-reason/post-init-ggtags ()
(add-hook 'reason-mode-local-vars-hook #'spacemacs/ggtags-mode-enabled))
(defun jf-reason/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'reason-mode))
(defun jf-reason/init-merlin ()
(use-package merlin
:defer t
:init
(progn
(add-to-list 'spacemacs-jump-handlers-reason-mode
'spacemacs/merlin-locate)
(add-hook 'reason-mode-hook 'merlin-mode)
(setq merlin-completion-with-doc t)
(spacemacs/set-leader-keys-for-major-mode 'reason-mode
"cp" 'merlin-project-check
"cv" 'merlin-goto-project-file
"eC" 'merlin-error-check
"en" 'merlin-error-next
"eN" 'merlin-error-prev
"gb" 'merlin-pop-stack
"gG" 'spacemacs/merlin-locate-other-window
"gl" 'merlin-locate-ident
"gi" 'merlin-switch-to-ml
"gI" 'merlin-switch-to-mli
"go" 'merlin-occurrences
"hh" 'merlin-document
"ht" 'merlin-type-enclosing
"hT" 'merlin-type-expr
"rd" 'merlin-destruct)
(spacemacs/declare-prefix-for-mode 'reason-mode "mc" "compile/check")
(spacemacs/declare-prefix-for-mode 'reason-mode "me" "errors")
(spacemacs/declare-prefix-for-mode 'reason-mode "mg" "goto")
(spacemacs/declare-prefix-for-mode 'reason-mode "mh" "help")
(spacemacs/declare-prefix-for-mode 'reason-mode "mr" "refactor"))))
(defun jf-reason/init-refmt ()
(add-hook 'reason-mode-hook (lambda ()
(add-hook 'before-save-hook 'refmt-before-save)
(merlin-mode)))
)
(defun jf-reason/init-reason-mode ()
(use-package reason-mode
:mode (("\\.re[i]?$" . reason-mode))
:defer t
:init
(setq opam (substring (shell-command-to-string "opam config var prefix 2> /dev/null") 0 -1))
(setq merlin-ac-setup t)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment