2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Haskell Layer packages File for Spacemacs
|
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; 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
|
2015-02-15 03:45:14 +00:00
|
|
|
company-ghc
|
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-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))
|
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun haskell/post-init-flycheck ()
|
2015-03-29 00:44:30 +00:00
|
|
|
(add-hook 'haskell-mode-hook 'flycheck-mode))
|
|
|
|
|
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
|
|
|
|
:init (add-hook 'haskell-mode-hook 'ghc-init)
|
|
|
|
:config
|
|
|
|
(when (configuration-layer/package-usedp 'flycheck)
|
2015-04-16 08:03:53 +00:00
|
|
|
;; 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 ()
|
|
|
|
(require 'haskell-yas)
|
|
|
|
(use-package haskell-mode
|
|
|
|
:defer t
|
|
|
|
: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-04-10 04:00:51 +00:00
|
|
|
(electric-indent-local-mode -1))
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2015-04-01 16:04:43 +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")
|
|
|
|
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-mode
|
|
|
|
"mu" 'haskell-mode-find-uses
|
2015-03-29 13:58:35 +00:00
|
|
|
"mht" 'haskell-mode-show-type-at
|
2015-04-01 16:04:43 +00:00
|
|
|
"mgg" 'haskell-mode-goto-loc))
|
|
|
|
|
|
|
|
;; hooks
|
|
|
|
(add-hook 'haskell-mode-hook 'spacemacs/init-haskell-mode)
|
2014-12-02 04:22:45 +00:00
|
|
|
(add-hook 'haskell-cabal-mode-hook 'haskell-cabal-hook)
|
2015-04-01 16:04:43 +00:00
|
|
|
(unless haskell-enable-shm-support
|
|
|
|
(add-hook 'haskell-mode-hook 'haskell-indentation-mode))
|
|
|
|
|
|
|
|
;; settings
|
|
|
|
(setq haskell-process-type 'auto
|
|
|
|
;; 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-error nil
|
|
|
|
;; Better import handling
|
|
|
|
haskell-process-suggest-remove-import-lines t
|
|
|
|
haskell-process-auto-import-loaded-modules t
|
|
|
|
;; Disable haskell-stylish on save, it breaks flycheck highlighting
|
|
|
|
haskell-stylish-on-save nil)
|
|
|
|
|
|
|
|
;; key bindings
|
|
|
|
(defun spacemacs/haskell-process-do-type-on-prev-line ()
|
|
|
|
(interactive)
|
|
|
|
(haskell-process-do-type 1))
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-mode
|
2015-01-21 03:32:13 +00:00
|
|
|
"mgg" 'haskell-mode-jump-to-def-or-tag
|
2014-12-22 10:49:15 +00:00
|
|
|
"mf" 'haskell-mode-stylish-buffer
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
"msb" 'haskell-process-load-or-reload
|
|
|
|
"msc" 'haskell-interactive-mode-clear
|
|
|
|
"mss" 'haskell-interactive-bring
|
|
|
|
"msS" 'haskell-interactive-switch
|
|
|
|
|
2014-12-22 10:49:15 +00:00
|
|
|
"mca" 'haskell-process-cabal
|
|
|
|
"mcb" 'haskell-process-cabal-build
|
|
|
|
"mcc" 'haskell-compile
|
|
|
|
"mcv" 'haskell-cabal-visit-file
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2015-03-18 12:51:20 +00:00
|
|
|
"mhd" 'inferior-haskell-find-haddock
|
2014-12-21 16:03:27 +00:00
|
|
|
"mhh" 'hoogle
|
2015-03-18 12:51:20 +00:00
|
|
|
"mhi" 'haskell-process-do-info
|
|
|
|
"mht" 'haskell-process-do-type
|
2015-04-01 16:04:43 +00:00
|
|
|
"mhT" 'spacemacs/haskell-process-do-type-on-prev-line
|
2014-12-21 16:03:27 +00:00
|
|
|
"mhy" 'hayoo
|
|
|
|
|
|
|
|
"mdd" 'haskell-debug
|
|
|
|
"mdb" 'haskell-debug/break-on-function
|
|
|
|
"mdn" 'haskell-debug/next
|
2014-12-22 10:49:15 +00:00
|
|
|
"mdN" 'haskell-debug/previous
|
2014-12-21 16:03:27 +00:00
|
|
|
"mdB" 'haskell-debug/delete
|
|
|
|
"mdc" 'haskell-debug/continue
|
|
|
|
"mda" 'haskell-debug/abandon
|
2015-04-01 16:04:43 +00:00
|
|
|
"mdr" 'haskell-debug/refresh)
|
2015-02-22 11:03:46 +00:00
|
|
|
|
2014-12-21 16:03:27 +00:00
|
|
|
;; Switch back to editor from REPL
|
2015-04-16 08:03:53 +00:00
|
|
|
(evil-leader/set-key-for-mode 'haskell-interactive-mode
|
2015-04-01 16:04:43 +00:00
|
|
|
"msS" 'haskell-interactive-switch)
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
;; Compile
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-cabal
|
2015-04-01 16:04:43 +00:00
|
|
|
"mC" 'haskell-compile)
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
;; Cabal-file bindings
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-cabal-mode
|
2015-04-01 16:04:43 +00:00
|
|
|
;; "m=" 'haskell-cabal-subsection-arrange-lines ;; Does a bad job, 'gg=G' works better
|
2014-12-21 16:03:27 +00:00
|
|
|
"md" 'haskell-cabal-add-dependency
|
|
|
|
"mb" 'haskell-cabal-goto-benchmark-section
|
|
|
|
"me" 'haskell-cabal-goto-executable-section
|
|
|
|
"mt" 'haskell-cabal-goto-test-suite-section
|
|
|
|
"mm" 'haskell-cabal-goto-exposed-modules
|
|
|
|
"ml" 'haskell-cabal-goto-library-section
|
|
|
|
"mn" 'haskell-cabal-next-subsection
|
|
|
|
"mp" 'haskell-cabal-previous-subsection
|
|
|
|
"mN" 'haskell-cabal-next-section
|
|
|
|
"mP" 'haskell-cabal-previous-section
|
2015-04-01 16:04:43 +00:00
|
|
|
"mf" '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
|
|
|
|
|
|
|
;; Useful to have these keybindings for .cabal files, too.
|
2015-04-01 16:04:43 +00:00
|
|
|
(eval-after-load 'haskell-cabal-mode-map
|
|
|
|
'(define-key haskell-cabal-mode-map
|
2015-04-16 08:03:53 +00:00
|
|
|
[?\C-c ?\C-z] 'haskell-interactive-switch))))
|
|
|
|
|
2015-04-19 05:11:31 +00:00
|
|
|
(eval-after-load 'haskell-indentation
|
2015-04-16 08:03:53 +00:00
|
|
|
(progn
|
|
|
|
;; Show indentation guides in insert or emacs state only.
|
|
|
|
(defun spacemacs//haskell-indentation-show-guides ()
|
|
|
|
"Show visual indentation guides."
|
|
|
|
(when (derived-mode-p 'haskell-mode)
|
|
|
|
(haskell-indentation-enable-show-indentations)))
|
|
|
|
|
|
|
|
(defun spacemacs//haskell-indentation-hide-guides ()
|
|
|
|
"Hide visual indentation guides."
|
|
|
|
(when (derived-mode-p 'haskell-mode)
|
|
|
|
(haskell-indentation-disable-show-indentations)))
|
|
|
|
|
|
|
|
;; first entry in normal state
|
|
|
|
(add-hook 'evil-normal-state-entry-hook 'spacemacs//haskell-indentation-hide-guides)
|
|
|
|
|
|
|
|
(add-hook 'evil-insert-state-entry-hook 'spacemacs//haskell-indentation-show-guides)
|
|
|
|
(add-hook 'evil-emacs-state-entry-hook 'spacemacs//haskell-indentation-show-guides)
|
|
|
|
(add-hook 'evil-insert-state-exit-hook 'spacemacs//haskell-indentation-hide-guides)
|
|
|
|
(add-hook 'evil-emacs-state-exit-hook 'spacemacs//haskell-indentation-hide-guides))))
|
2015-01-15 04:23:08 +00:00
|
|
|
|
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)
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-mode
|
|
|
|
"mF" 'hindent/reformat-decl))))
|
|
|
|
|
|
|
|
(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
|
|
|
|
(kbd "M-RET") 'evil-ret
|
|
|
|
)
|
|
|
|
|
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))))
|
|
|
|
|
2015-04-03 23:13:52 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
2015-04-03 22:37:01 +00:00
|
|
|
(defun haskell/post-init-company ()
|
2015-04-09 03:57:22 +00:00
|
|
|
(spacemacs|add-company-hook haskell-mode))
|
2015-04-03 21:12:56 +00:00
|
|
|
|
|
|
|
(defun haskell/init-company-ghc ()
|
|
|
|
(use-package company-ghc
|
2015-04-09 03:57:22 +00:00
|
|
|
:if (configuration-layer/package-usedp 'company)
|
2015-04-03 21:12:56 +00:00
|
|
|
:defer t
|
2015-04-07 03:41:27 +00:00
|
|
|
:init
|
2015-04-10 04:00:51 +00:00
|
|
|
(push '(company-ghc company-dabbrev-code company-yasnippet)
|
|
|
|
company-backends-haskell-mode))))
|