2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Haskell Layer packages File for Spacemacs
|
|
|
|
;;
|
2017-01-06 03:51:13 +00:00
|
|
|
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq haskell-packages
|
2014-12-12 03:34:13 +00:00
|
|
|
'(
|
2015-04-03 22:37:01 +00:00
|
|
|
cmm-mode
|
2016-05-01 15:36:11 +00:00
|
|
|
(company-cabal :toggle (configuration-layer/package-usedp 'company))
|
2016-06-24 15:37:01 +00:00
|
|
|
company-ghci
|
|
|
|
company-ghc
|
2016-04-05 04:08:34 +00:00
|
|
|
flycheck
|
2016-07-17 15:36:07 +00:00
|
|
|
(flycheck-haskell :toggle (configuration-layer/package-usedp 'flycheck))
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
2016-06-24 15:37:01 +00:00
|
|
|
ghc
|
2014-12-12 03:34:13 +00:00
|
|
|
haskell-mode
|
2015-05-03 16:51:29 +00:00
|
|
|
haskell-snippets
|
2016-04-05 04:08:34 +00:00
|
|
|
helm-gtags
|
2016-05-30 02:39:21 +00:00
|
|
|
(helm-hoogle :toggle (configuration-layer/package-usedp 'helm))
|
2015-03-01 05:00:10 +00:00
|
|
|
hindent
|
2016-05-30 04:07:37 +00:00
|
|
|
hlint-refactor
|
2016-07-17 15:36:07 +00:00
|
|
|
intero
|
2017-05-27 20:57:22 +00:00
|
|
|
dante
|
2014-12-21 16:03:27 +00:00
|
|
|
))
|
|
|
|
|
2015-04-03 22:37:01 +00:00
|
|
|
(defun haskell/init-cmm-mode ()
|
|
|
|
(use-package cmm-mode
|
|
|
|
:defer t))
|
|
|
|
|
2016-05-01 15:36:11 +00:00
|
|
|
(defun haskell/init-company-cabal ()
|
|
|
|
(use-package company-cabal
|
|
|
|
:defer t
|
2017-01-02 05:39:04 +00:00
|
|
|
:init (spacemacs|add-company-backends
|
|
|
|
:backends company-cabal
|
|
|
|
:modes haskell-cabal-mode)))
|
2016-05-01 15:36:11 +00:00
|
|
|
|
2016-06-10 16:53:07 +00:00
|
|
|
(defun haskell/init-company-ghci ()
|
|
|
|
(use-package company-ghci
|
2016-06-24 15:37:01 +00:00
|
|
|
:defer t))
|
2015-03-29 00:44:30 +00:00
|
|
|
|
2016-06-10 16:53:07 +00:00
|
|
|
(defun haskell/init-company-ghc ()
|
|
|
|
(use-package company-ghc
|
2016-06-24 15:37:01 +00:00
|
|
|
:defer t))
|
2014-12-12 03:34:13 +00:00
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun haskell/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'haskell-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2015-04-10 04:00:51 +00:00
|
|
|
(defun haskell/init-ghc ()
|
|
|
|
(use-package ghc
|
2016-06-24 15:37:01 +00:00
|
|
|
:defer t))
|
2015-03-10 13:54:51 +00:00
|
|
|
|
2017-05-27 20:57:22 +00:00
|
|
|
(defun haskell/init-dante ()
|
|
|
|
(use-package dante
|
|
|
|
:defer t
|
|
|
|
:init (add-hook 'haskell-mode-hook 'dante-mode)))
|
|
|
|
|
2016-06-10 16:53:07 +00:00
|
|
|
(defun haskell/init-intero ()
|
|
|
|
(use-package intero
|
2016-06-24 15:37:01 +00:00
|
|
|
:defer t
|
2016-06-10 16:53:07 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|diminish intero-mode " λ" " \\")
|
|
|
|
(advice-add 'intero-repl-load
|
2016-06-24 15:37:01 +00:00
|
|
|
:around #'haskell-intero//preserve-focus))))
|
2016-06-10 16:53:07 +00:00
|
|
|
|
|
|
|
(defun haskell/init-helm-hoogle ()
|
|
|
|
(use-package helm-hoogle
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(dolist (mode haskell-modes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "hf" 'helm-hoogle))))
|
|
|
|
|
|
|
|
(defun haskell/post-init-flycheck ()
|
2017-02-14 03:27:29 +00:00
|
|
|
(spacemacs/enable-flycheck 'haskell-mode))
|
2016-06-10 16:53:07 +00:00
|
|
|
|
|
|
|
(defun haskell/init-flycheck-haskell ()
|
|
|
|
(use-package flycheck-haskell
|
|
|
|
:commands flycheck-haskell-configure
|
|
|
|
:init (add-hook 'flycheck-mode-hook 'flycheck-haskell-configure)))
|
|
|
|
|
2014-12-02 04:22:45 +00:00
|
|
|
(defun haskell/init-haskell-mode ()
|
|
|
|
(use-package haskell-mode
|
|
|
|
:defer t
|
2015-11-02 20:24:17 +00:00
|
|
|
:init
|
2015-11-03 04:16:57 +00:00
|
|
|
(progn
|
2016-06-26 18:04:13 +00:00
|
|
|
(add-hook 'haskell-mode-local-vars-hook
|
|
|
|
#'spacemacs-haskell//setup-completion-backend)
|
2016-06-24 15:37:01 +00:00
|
|
|
|
2015-11-03 04:16:57 +00:00
|
|
|
(defun spacemacs//force-haskell-mode-loading ()
|
|
|
|
"Force `haskell-mode' loading when visiting cabal file."
|
|
|
|
(require 'haskell-mode))
|
|
|
|
(add-hook 'haskell-cabal-mode-hook
|
2016-06-24 15:37:01 +00:00
|
|
|
'spacemacs//force-haskell-mode-loading)
|
|
|
|
|
2017-02-02 12:11:57 +00:00
|
|
|
;; Haskell cabal files interact badly with electric-indent-mode
|
|
|
|
;; note: we cannot add this hook in :config, since haskell-mode might
|
|
|
|
;; only be loaded after cabal-mode hooks are already run (see add-hook above)
|
|
|
|
(add-hook 'haskell-cabal-mode-hook #'spacemacs-haskell//disable-electric-indent)
|
|
|
|
|
2016-06-24 15:37:01 +00:00
|
|
|
(setq
|
|
|
|
;; Use notify.el (if you have it installed) at the end of running
|
|
|
|
;; Cabal commands or generally things worth notifying.
|
|
|
|
haskell-notify-p t
|
|
|
|
;; Remove annoying error popups
|
|
|
|
haskell-interactive-popup-errors nil
|
|
|
|
;; Better import handling
|
|
|
|
haskell-process-suggest-remove-import-lines t
|
|
|
|
haskell-process-auto-import-loaded-modules t
|
|
|
|
;; Disable haskell-stylish-on-save, as it breaks flycheck highlighting.
|
|
|
|
;; NOTE: May not be true anymore - taksuyu 2015-10-06
|
2016-09-05 02:29:41 +00:00
|
|
|
haskell-stylish-on-save nil))
|
2014-12-02 04:22:45 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-10-24 07:58:12 +00:00
|
|
|
(defun spacemacs/haskell-interactive-bring ()
|
|
|
|
"Bring up the interactive mode for this session without
|
|
|
|
switching to it."
|
|
|
|
(interactive)
|
|
|
|
(let* ((session (haskell-session))
|
|
|
|
(buffer (haskell-session-interactive-buffer session)))
|
|
|
|
(display-buffer buffer)))
|
|
|
|
|
2015-04-01 16:04:43 +00:00
|
|
|
;; hooks
|
2017-05-23 13:34:24 +00:00
|
|
|
(add-hook 'haskell-mode-hook #'spacemacs-haskell//disable-electric-indent)
|
2015-04-01 16:04:43 +00:00
|
|
|
|
2015-10-16 05:59:50 +00:00
|
|
|
;; prefixes
|
2016-02-07 18:48:44 +00:00
|
|
|
(dolist (mode haskell-modes)
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mg" "haskell/navigation")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "ms" "haskell/repl")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mc" "haskell/cabal")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mh" "haskell/documentation")
|
2016-08-29 14:01:53 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "md" "haskell/debug")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mr" "haskell/refactor"))
|
2015-10-24 08:06:55 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'haskell-interactive-mode "ms" "haskell/repl")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'haskell-cabal-mode "ms" "haskell/repl")
|
2015-10-16 05:59:50 +00:00
|
|
|
|
2015-04-01 16:04:43 +00:00
|
|
|
;; key bindings
|
|
|
|
(defun spacemacs/haskell-process-do-type-on-prev-line ()
|
|
|
|
(interactive)
|
2016-06-10 16:53:07 +00:00
|
|
|
(haskell-process-do-type 1))
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2016-02-07 18:48:44 +00:00
|
|
|
(dolist (mode haskell-modes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"gi" 'haskell-navigate-imports
|
2016-07-27 20:10:48 +00:00
|
|
|
"F" 'haskell-mode-stylish-buffer
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2016-02-07 18:48:44 +00:00
|
|
|
"sb" 'haskell-process-load-file
|
|
|
|
"sc" 'haskell-interactive-mode-clear
|
|
|
|
"ss" 'spacemacs/haskell-interactive-bring
|
|
|
|
"sS" 'haskell-interactive-switch
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2016-02-07 18:48:44 +00:00
|
|
|
"ca" 'haskell-process-cabal
|
|
|
|
"cb" 'haskell-process-cabal-build
|
|
|
|
"cc" 'haskell-compile
|
|
|
|
"cv" 'haskell-cabal-visit-file
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2016-02-07 18:48:44 +00:00
|
|
|
"hd" 'inferior-haskell-find-haddock
|
|
|
|
"hh" 'hoogle
|
|
|
|
"hH" 'haskell-hoogle-lookup-from-local
|
2016-06-10 16:53:07 +00:00
|
|
|
"hi" 'haskell-process-do-info
|
|
|
|
"ht" 'haskell-process-do-type
|
2016-02-07 18:48:44 +00:00
|
|
|
"hT" 'spacemacs/haskell-process-do-type-on-prev-line
|
|
|
|
"hy" 'hayoo
|
2015-11-18 00:38:05 +00:00
|
|
|
|
2016-06-08 03:36:06 +00:00
|
|
|
"da" 'haskell-debug/abandon
|
2016-02-07 18:48:44 +00:00
|
|
|
"db" 'haskell-debug/break-on-function
|
|
|
|
"dB" 'haskell-debug/delete
|
|
|
|
"dc" 'haskell-debug/continue
|
2016-06-08 03:36:06 +00:00
|
|
|
"dd" 'haskell-debug
|
|
|
|
"dn" 'haskell-debug/next
|
|
|
|
"dN" 'haskell-debug/previous
|
|
|
|
"dp" 'haskell-debug/previous
|
|
|
|
"dr" 'haskell-debug/refresh
|
|
|
|
"ds" 'haskell-debug/step
|
|
|
|
"dt" 'haskell-debug/trace))
|
2015-02-22 11:03:46 +00:00
|
|
|
|
2016-05-18 06:24:39 +00:00
|
|
|
(evilified-state-evilify haskell-debug-mode haskell-debug-mode-map
|
|
|
|
"RET" 'haskell-debug/select
|
|
|
|
"a" 'haskell-debug/abandon
|
|
|
|
"b" 'haskell-debug/break-on-function
|
|
|
|
"c" 'haskell-debug/continue
|
|
|
|
"d" 'haskell-debug/delete
|
2017-02-12 18:02:55 +00:00
|
|
|
"i" 'haskell-debug/step
|
|
|
|
"s" 'haskell-debug/next
|
|
|
|
"S" 'haskell-debug/previous
|
2016-06-08 03:36:06 +00:00
|
|
|
"r" 'haskell-debug/refresh
|
2016-05-18 06:24:39 +00:00
|
|
|
"t" 'haskell-debug/trace)
|
|
|
|
|
2015-10-25 10:11:41 +00:00
|
|
|
;; configure C-c C-l so it doesn't throw any errors
|
2015-12-09 19:59:42 +00:00
|
|
|
(bind-key "C-c C-l" 'haskell-process-load-file haskell-mode-map)
|
2015-10-25 10:11:41 +00:00
|
|
|
|
2014-12-21 16:03:27 +00:00
|
|
|
;; Switch back to editor from REPL
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'haskell-interactive-mode
|
|
|
|
"sS" 'haskell-interactive-switch-back)
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
;; Compile
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'haskell-cabal
|
|
|
|
"C" 'haskell-compile)
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
;; Cabal-file bindings
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'haskell-cabal-mode
|
|
|
|
;; "=" 'haskell-cabal-subsection-arrange-lines ;; Does a bad job, 'gg=G' works better
|
|
|
|
"d" 'haskell-cabal-add-dependency
|
|
|
|
"b" 'haskell-cabal-goto-benchmark-section
|
|
|
|
"e" 'haskell-cabal-goto-executable-section
|
|
|
|
"t" 'haskell-cabal-goto-test-suite-section
|
|
|
|
"m" 'haskell-cabal-goto-exposed-modules
|
|
|
|
"l" 'haskell-cabal-goto-library-section
|
|
|
|
"n" 'haskell-cabal-next-subsection
|
|
|
|
"p" 'haskell-cabal-previous-subsection
|
|
|
|
"sc" 'haskell-interactive-mode-clear
|
|
|
|
"ss" 'spacemacs/haskell-interactive-bring
|
|
|
|
"sS" 'haskell-interactive-switch
|
|
|
|
"N" 'haskell-cabal-next-section
|
|
|
|
"P" 'haskell-cabal-previous-section
|
|
|
|
"f" 'haskell-cabal-find-or-create-source-file)
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2015-04-01 16:04:43 +00:00
|
|
|
;; Make "RET" behaviour in REPL saner
|
|
|
|
(evil-define-key 'insert haskell-interactive-mode-map
|
|
|
|
(kbd "RET") 'haskell-interactive-mode-return)
|
|
|
|
(evil-define-key 'normal haskell-interactive-mode-map
|
2016-06-10 16:53:07 +00:00
|
|
|
(kbd "RET") 'haskell-interactive-mode-return))
|
2015-05-10 12:08:11 +00:00
|
|
|
|
2015-10-08 15:11:09 +00:00
|
|
|
;; align rules for Haskell
|
|
|
|
(with-eval-after-load 'align
|
|
|
|
(add-to-list 'align-rules-list
|
|
|
|
'(haskell-types
|
|
|
|
(regexp . "\\(\\s-+\\)\\(::\\|∷\\)\\s-+")
|
2016-02-07 18:48:44 +00:00
|
|
|
(modes . haskell-modes)))
|
2015-10-08 15:11:09 +00:00
|
|
|
(add-to-list 'align-rules-list
|
|
|
|
'(haskell-assignment
|
|
|
|
(regexp . "\\(\\s-+\\)=\\s-+")
|
2016-02-07 18:48:44 +00:00
|
|
|
(modes . haskell-modes)))
|
2015-10-08 15:11:09 +00:00
|
|
|
(add-to-list 'align-rules-list
|
|
|
|
'(haskell-arrows
|
|
|
|
(regexp . "\\(\\s-+\\)\\(->\\|→\\)\\s-+")
|
2016-02-07 18:48:44 +00:00
|
|
|
(modes . haskell-modes)))
|
2015-10-08 15:11:09 +00:00
|
|
|
(add-to-list 'align-rules-list
|
|
|
|
'(haskell-left-arrows
|
|
|
|
(regexp . "\\(\\s-+\\)\\(<-\\|←\\)\\s-+")
|
2016-02-07 18:48:44 +00:00
|
|
|
(modes . haskell-modes))))))
|
2015-01-15 04:23:08 +00:00
|
|
|
|
2015-05-03 16:51:29 +00:00
|
|
|
(defun haskell/init-haskell-snippets ()
|
2015-05-04 04:27:13 +00:00
|
|
|
;; manually load the package since the current implementation is not lazy
|
|
|
|
;; loading friendly (funny coming from the haskell mode :-))
|
2017-01-17 05:20:59 +00:00
|
|
|
(setq haskell-snippets-dir
|
|
|
|
(configuration-layer/get-elpa-package-install-directory
|
|
|
|
'haskell-snippets))
|
2015-05-04 04:27:13 +00:00
|
|
|
|
|
|
|
(defun haskell-snippets-initialize ()
|
|
|
|
(let ((snip-dir (expand-file-name "snippets" haskell-snippets-dir)))
|
|
|
|
(add-to-list 'yas-snippet-dirs snip-dir t)
|
|
|
|
(yas-load-directory snip-dir)))
|
|
|
|
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'yasnippet (haskell-snippets-initialize)))
|
2015-05-03 16:51:29 +00:00
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun haskell/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'haskell-mode))
|
|
|
|
|
2016-02-07 18:48:44 +00:00
|
|
|
;; doesn't support literate-haskell-mode :(
|
2015-04-03 21:12:56 +00:00
|
|
|
(defun haskell/init-hindent ()
|
|
|
|
(use-package hindent
|
|
|
|
:defer t
|
|
|
|
:if (stringp haskell-enable-hindent-style)
|
|
|
|
:init
|
|
|
|
(add-hook 'haskell-mode-hook #'hindent-mode)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(setq hindent-style haskell-enable-hindent-style)
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'haskell-mode
|
2016-07-27 20:10:48 +00:00
|
|
|
"f" 'hindent-reformat-decl))))
|
2015-04-03 21:12:56 +00:00
|
|
|
|
2016-05-30 04:07:37 +00:00
|
|
|
(defun haskell/init-hlint-refactor ()
|
|
|
|
(use-package hlint-refactor
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'haskell-mode
|
|
|
|
"rb" 'hlint-refactor-refactor-buffer
|
|
|
|
"rr" 'hlint-refactor-refactor-at-point))))
|