add dante support to haskell layer

This commit is contained in:
Kyle McKean 2017-05-27 16:57:22 -04:00 committed by Eivind Fonn
parent e425d50292
commit 1ed49e0878
4 changed files with 35 additions and 4 deletions

View File

@ -12,6 +12,7 @@
- [[#completion-support][Completion support]]
- [[#company-ghci][=company-ghci=]]
- [[#intero][=intero=]]
- [[#dante][=dante=]]
- [[#ghc-mod][=ghc-mod=]]
- [[#optional-extras][Optional extras]]
- [[#structured-haskell-mode][structured-haskell-mode]]
@ -119,6 +120,9 @@ order to use it you have to call =haskell-process-load-or-reload= (=SPC s b=).
calling =stack install intero=, but this step is optional as =Intero= installs
itself.
*** =dante=
=dante= works for =cabal=, =nix=, =sytx=, and =stack= users.
*** =ghc-mod=
[[http://www.mew.org/~kazu/proj/ghc-mod/][ghc-mod]] enhances =haskell-mode= with for example code completion, templates,
case-splitting and much more. In order to use it you need to install the

View File

@ -18,7 +18,7 @@
(defvar haskell-completion-backend 'ghci
"Completion backend used by company.
Available options are `ghci', `intero' and `ghc-mod'. Default is
Available options are `ghci', `intero', `dante', and `ghc-mod'. Default is
`ghci'.")
(defvar haskell-enable-hindent-style nil

View File

@ -11,15 +11,15 @@
(defun spacemacs-haskell//setup-completion-backend ()
"Conditionally setup haskell completion backend."
(unless (eq haskell-completion-backend 'ghc-mod)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode))
(when (configuration-layer/package-usedp 'company)
(pcase haskell-completion-backend
(`ghci (spacemacs-haskell//setup-ghci))
(`ghc-mod (spacemacs-haskell//setup-ghc-mod))
(`intero (spacemacs-haskell//setup-intero)))))
(`intero (spacemacs-haskell//setup-intero))
(`dante (spacemacs-haskell//setup-dante)))))
(defun spacemacs-haskell//setup-ghci ()
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(spacemacs|add-company-backends
:backends (company-ghci company-dabbrev-code company-yasnippet)
:modes haskell-mode))
@ -48,7 +48,22 @@
(set-face-attribute 'ghc-face-error nil :underline nil)
(set-face-attribute 'ghc-face-warn nil :underline nil)))
(defun spacemacs-haskell//setup-dante ()
(spacemacs|add-company-backends
:backends (company-dante company-dabbrev-code company-yasnippet)
:modes haskell-mode)
(push 'xref-find-definitions spacemacs-jump-handlers)
(dolist (mode haskell-modes)
(spacemacs/set-leader-keys-for-major-mode mode
"ht" 'dante-type-at
"hT" 'spacemacs-haskell//dante-insert-type
"hi" 'dante-info
"rs" 'dante-auto-fix
"se" 'dante-eval-block
"sr" 'dante-restart)))
(defun spacemacs-haskell//setup-intero ()
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(spacemacs|add-company-backends
:backends (company-intero company-dabbrev-code company-yasnippet)
:modes haskell-mode)
@ -87,6 +102,12 @@
(if (fboundp 'electric-indent-local-mode)
(electric-indent-local-mode -1)))
;; Dante Functions
(defun spacemacs-haskell//dante-insert-type ()
(interactive)
(dante-type-at :insert))
;; Intero functions

View File

@ -26,6 +26,7 @@
hindent
hlint-refactor
intero
dante
))
(defun haskell/init-cmm-mode ()
@ -54,6 +55,11 @@
(use-package ghc
:defer t))
(defun haskell/init-dante ()
(use-package dante
:defer t
:init (add-hook 'haskell-mode-hook 'dante-mode)))
(defun haskell/init-intero ()
(use-package intero
:defer t