2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Haskell Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 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
|
2015-04-09 03:57:22 +00:00
|
|
|
company
|
2016-05-01 15:36:11 +00:00
|
|
|
(company-cabal :toggle (configuration-layer/package-usedp 'company))
|
|
|
|
(company-ghc :toggle (and (configuration-layer/package-usedp 'company)
|
|
|
|
haskell-enable-ghc-mod-support))
|
|
|
|
(company-ghci :toggle (and (configuration-layer/package-usedp 'company)
|
|
|
|
(not haskell-enable-ghc-mod-support)))
|
2015-03-29 00:44:30 +00:00
|
|
|
flycheck
|
2014-12-22 10:49:15 +00:00
|
|
|
flycheck-haskell
|
2014-12-14 04:31:03 +00:00
|
|
|
ghc
|
2014-12-12 03:34:13 +00:00
|
|
|
haskell-mode
|
2015-05-03 16:51:29 +00:00
|
|
|
haskell-snippets
|
2016-01-14 19:28:06 +00:00
|
|
|
helm-hoogle
|
2015-03-01 05:00:10 +00:00
|
|
|
hindent
|
|
|
|
shm
|
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/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook haskell-mode)
|
|
|
|
(spacemacs|add-company-hook haskell-cabal-mode))
|
|
|
|
|
|
|
|
(defun haskell/init-company-ghc ()
|
|
|
|
(use-package company-ghc
|
|
|
|
:defer t
|
|
|
|
:init (push '(company-ghc company-dabbrev-code company-yasnippet)
|
|
|
|
company-backends-haskell-mode)))
|
|
|
|
|
|
|
|
(defun haskell/init-company-ghci ()
|
|
|
|
(use-package company-ghc
|
|
|
|
:defer t
|
|
|
|
:init (push '(company-ghci company-dabbrev-code company-yasnippet)
|
|
|
|
company-backends-haskell-mode)))
|
|
|
|
|
|
|
|
(defun haskell/init-company-cabal ()
|
|
|
|
(use-package company-cabal
|
|
|
|
:if (configuration-layer/package-usedp 'company)
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(push '(company-cabal)
|
|
|
|
company-backends-haskell-cabal-mode)))
|
|
|
|
|
2016-05-16 02:24:27 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'helm)
|
2016-01-14 19:28:06 +00:00
|
|
|
(defun haskell/init-helm-hoogle ()
|
|
|
|
(use-package helm-hoogle
|
|
|
|
:defer t
|
|
|
|
:init
|
2016-02-07 18:48:44 +00:00
|
|
|
(dolist (mode haskell-modes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "hf" 'helm-hoogle)))))
|
2016-01-14 19:28:06 +00:00
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun haskell/post-init-flycheck ()
|
2016-01-27 20:08:25 +00:00
|
|
|
(spacemacs/add-flycheck-hook 'haskell-mode))
|
2015-03-29 00:44:30 +00:00
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'syntax-checking)
|
|
|
|
(defun haskell/init-flycheck-haskell ()
|
|
|
|
(use-package flycheck-haskell
|
|
|
|
:if (configuration-layer/package-usedp 'flycheck)
|
|
|
|
:commands flycheck-haskell-configure
|
|
|
|
:init (add-hook 'flycheck-mode-hook 'flycheck-haskell-configure))))
|
2014-12-12 03:34:13 +00:00
|
|
|
|
2015-04-10 04:00:51 +00:00
|
|
|
(defun haskell/init-ghc ()
|
|
|
|
(use-package ghc
|
|
|
|
:defer t
|
2015-06-17 05:40:30 +00:00
|
|
|
:if haskell-enable-ghc-mod-support
|
2015-04-10 04:00:51 +00:00
|
|
|
:init (add-hook 'haskell-mode-hook 'ghc-init)
|
|
|
|
:config
|
2015-11-05 14:16:26 +00:00
|
|
|
(progn
|
2016-02-07 18:48:44 +00:00
|
|
|
(dolist (mode haskell-modes)
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mm" "haskell/ghc-mod")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2015-11-18 00:38:05 +00:00
|
|
|
"mt" 'ghc-insert-template-or-signature
|
|
|
|
"mu" 'ghc-initial-code-from-signature
|
|
|
|
"ma" 'ghc-auto
|
|
|
|
"mf" 'ghc-refine
|
|
|
|
"me" 'ghc-expand-th
|
|
|
|
"mn" 'ghc-goto-next-hole
|
|
|
|
"mp" 'ghc-goto-prev-hole
|
|
|
|
"m>" 'ghc-make-indent-deeper
|
2016-02-07 18:48:44 +00:00
|
|
|
"m<" 'ghc-make-indent-shallower))
|
2015-11-05 14:16:26 +00:00
|
|
|
(when (configuration-layer/package-usedp 'flycheck)
|
|
|
|
;; remove overlays from ghc-check.el if flycheck is enabled
|
|
|
|
(set-face-attribute 'ghc-face-error nil :underline nil)
|
|
|
|
(set-face-attribute 'ghc-face-warn nil :underline nil)))))
|
2015-03-10 13:54:51 +00:00
|
|
|
|
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
|
|
|
|
(defun spacemacs//force-haskell-mode-loading ()
|
|
|
|
"Force `haskell-mode' loading when visiting cabal file."
|
|
|
|
(require 'haskell-mode))
|
|
|
|
(add-hook 'haskell-cabal-mode-hook
|
|
|
|
'spacemacs//force-haskell-mode-loading))
|
2015-10-20 21:18:47 +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
|
|
|
|
;; To enable tags generation on save.
|
|
|
|
haskell-tags-on-save 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
|
|
|
|
haskell-stylish-on-save nil)
|
2014-12-02 04:22:45 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-04-01 16:04:43 +00:00
|
|
|
;; Haskell main editing mode key bindings.
|
|
|
|
(defun spacemacs/init-haskell-mode ()
|
2015-04-01 16:08:31 +00:00
|
|
|
;; use only internal indentation system from haskell
|
2015-06-20 02:00:13 +00:00
|
|
|
(if (fboundp 'electric-indent-local-mode)
|
2015-09-02 13:54:39 +00:00
|
|
|
(electric-indent-local-mode -1))
|
|
|
|
(when haskell-enable-shm-support
|
|
|
|
;; in structured-haskell-mode line highlighting creates noise
|
2015-09-07 19:05:59 +00:00
|
|
|
(setq-local global-hl-line-mode nil)))
|
2014-12-21 16:03:27 +00:00
|
|
|
|
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
|
|
|
|
(add-hook 'haskell-mode-hook 'spacemacs/init-haskell-mode)
|
2015-11-20 06:14:36 +00:00
|
|
|
(unless haskell-enable-ghc-mod-support
|
|
|
|
(add-hook 'haskell-mode-hook 'interactive-haskell-mode))
|
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")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "md" "haskell/debug"))
|
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)
|
2015-05-22 12:02:13 +00:00
|
|
|
(if haskell-enable-ghci-ng-support
|
|
|
|
(haskell-mode-show-type-at 1)
|
|
|
|
(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
|
|
|
|
"gg" 'haskell-mode-jump-to-def-or-tag
|
|
|
|
"gi" 'haskell-navigate-imports
|
|
|
|
"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
|
|
|
|
"hi" (lookup-key haskell-mode-map (kbd "C-c TAB"))
|
|
|
|
"ht" (lookup-key haskell-mode-map (kbd "C-c C-t"))
|
|
|
|
"hT" 'spacemacs/haskell-process-do-type-on-prev-line
|
|
|
|
"hy" 'hayoo
|
2015-11-18 00:38:05 +00:00
|
|
|
|
2016-02-07 18:48:44 +00:00
|
|
|
"dd" 'haskell-debug
|
|
|
|
"db" 'haskell-debug/break-on-function
|
|
|
|
"dn" 'haskell-debug/next
|
|
|
|
"dN" 'haskell-debug/previous
|
|
|
|
"dB" 'haskell-debug/delete
|
|
|
|
"dc" 'haskell-debug/continue
|
|
|
|
"da" 'haskell-debug/abandon
|
|
|
|
"dr" 'haskell-debug/refresh))
|
2015-02-22 11:03:46 +00:00
|
|
|
|
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
|
|
|
|
(kbd "RET") 'haskell-interactive-mode-return)
|
2014-12-02 04:22:45 +00:00
|
|
|
|
2015-05-04 16:07:36 +00:00
|
|
|
;;GHCi-ng
|
|
|
|
(when haskell-enable-ghci-ng-support
|
|
|
|
;; haskell-process-type is set to auto, so setup ghci-ng for either case
|
|
|
|
;; if haskell-process-type == cabal-repl
|
|
|
|
(setq haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans" "--with-ghc=ghci-ng"))
|
|
|
|
;; if haskell-process-type == GHCi
|
|
|
|
(setq haskell-process-path-ghci "ghci-ng")
|
2015-12-22 14:27:33 +00:00
|
|
|
;; fixes ghci-ng for stack projects
|
|
|
|
(setq haskell-process-wrapper-function
|
|
|
|
(lambda (args)
|
|
|
|
(append args (list "--with-ghc" "ghci-ng"))))
|
2015-05-04 16:07:36 +00:00
|
|
|
|
2016-02-07 18:48:44 +00:00
|
|
|
(dolist (mode haskell-modes)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
;; function suggested in
|
|
|
|
;; https://github.com/chrisdone/ghci-ng#using-with-haskell-mode
|
|
|
|
"u" 'haskell-mode-find-uses
|
|
|
|
"ht" 'haskell-mode-show-type-at
|
|
|
|
"gg" 'haskell-mode-goto-loc))
|
2015-05-04 16:07:36 +00:00
|
|
|
|
2015-05-10 12:08:11 +00:00
|
|
|
;; Useful to have these keybindings for .cabal files, too.
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'haskell-cabal-mode-map
|
|
|
|
(define-key haskell-cabal-mode-map
|
|
|
|
[?\C-c ?\C-z] 'haskell-interactive-switch))))
|
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 :-))
|
|
|
|
(setq haskell-snippets-dir (spacemacs//get-package-directory
|
|
|
|
'haskell-snippets))
|
|
|
|
|
|
|
|
(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-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
|
2015-12-02 21:32:44 +00:00
|
|
|
"F" 'hindent-reformat-decl))))
|
2015-04-03 21:12:56 +00:00
|
|
|
|
|
|
|
(defun haskell/init-shm ()
|
|
|
|
(use-package shm
|
|
|
|
:defer t
|
|
|
|
:if haskell-enable-shm-support
|
|
|
|
:init
|
|
|
|
(add-hook 'haskell-mode-hook 'structured-haskell-mode)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(when (require 'shm-case-split nil 'noerror)
|
|
|
|
;;TODO: Find some better bindings for case-splits
|
|
|
|
(define-key shm-map (kbd "C-c S") 'shm/case-split)
|
|
|
|
(define-key shm-map (kbd "C-c C-s") 'shm/do-case-split))
|
|
|
|
|
|
|
|
(evil-define-key 'normal shm-map
|
|
|
|
(kbd "RET") nil
|
|
|
|
(kbd "C-k") nil
|
|
|
|
(kbd "C-j") nil
|
|
|
|
(kbd "D") 'shm/kill-line
|
|
|
|
(kbd "R") 'shm/raise
|
|
|
|
(kbd "P") 'shm/yank
|
|
|
|
(kbd "RET") 'shm/newline-indent
|
|
|
|
(kbd "RET") 'shm/newline-indent
|
2016-05-01 15:36:11 +00:00
|
|
|
(kbd "M-RET") 'evil-ret)
|
2015-04-03 21:12:56 +00:00
|
|
|
|
2015-04-16 08:03:53 +00:00
|
|
|
(evil-define-key 'operator shm-map
|
2015-04-03 21:12:56 +00:00
|
|
|
(kbd ")") 'shm/forward-node
|
|
|
|
(kbd "(") 'shm/backward-node)
|
|
|
|
|
2015-04-16 08:03:53 +00:00
|
|
|
(evil-define-key 'motion shm-map
|
2015-04-03 21:12:56 +00:00
|
|
|
(kbd ")") 'shm/forward-node
|
|
|
|
(kbd "(") 'shm/backward-node)
|
|
|
|
|
|
|
|
(define-key shm-map (kbd "C-j") nil)
|
|
|
|
(define-key shm-map (kbd "C-k") nil))))
|
|
|
|
|