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
|
|
|
|
|
2014-12-12 03:34:13 +00:00
|
|
|
(defvar haskell-packages
|
|
|
|
'(
|
2015-02-15 03:45:14 +00:00
|
|
|
company-ghc
|
2014-12-12 03:34:13 +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
|
2014-12-30 23:21:48 +00:00
|
|
|
hi2
|
2015-03-01 05:00:10 +00:00
|
|
|
hindent
|
|
|
|
shm
|
2014-12-21 16:03:27 +00:00
|
|
|
))
|
|
|
|
|
2014-12-12 03:34:13 +00:00
|
|
|
(defun haskell/init-flycheck ()
|
2014-12-22 10:49:15 +00:00
|
|
|
;;(add-hook 'haskell-mode-hook 'flycheck-mode))
|
|
|
|
(add-hook 'flycheck-mode-hook 'flycheck-haskell-setup))
|
2014-12-12 03:34:13 +00:00
|
|
|
|
2015-02-23 18:16:47 +00:00
|
|
|
(defun haskell/init-shm ()
|
|
|
|
(use-package shm
|
|
|
|
:defer t
|
2015-02-25 01:04:50 +00:00
|
|
|
:if haskell-enable-shm-support
|
2015-02-23 18:16:47 +00:00
|
|
|
:init
|
2015-02-25 16:56:31 +00:00
|
|
|
(add-hook 'haskell-mode-hook 'structured-haskell-mode)))
|
|
|
|
|
|
|
|
(defun haskell/init-hindent ()
|
|
|
|
(use-package hindent
|
|
|
|
:defer t
|
|
|
|
:if haskell-enable-hindent-support
|
|
|
|
:init
|
|
|
|
(add-hook 'haskell-mode-hook #'hindent-mode)
|
2015-02-23 18:16:47 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-02-25 16:56:31 +00:00
|
|
|
(evil-leader/set-key-for-mode 'haskell-mode
|
|
|
|
"mF" 'hindent/reformat-decl))))
|
2015-02-23 18:16:47 +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
|
|
|
|
;; Customization
|
|
|
|
(custom-set-variables
|
2015-02-22 11:03:46 +00:00
|
|
|
|
2014-12-28 17:29:35 +00:00
|
|
|
'(haskell-process-type 'auto)
|
2014-12-02 04:22:45 +00:00
|
|
|
|
|
|
|
;; 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)
|
|
|
|
|
2014-12-21 16:03:27 +00:00
|
|
|
;; 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)
|
|
|
|
|
2014-12-22 10:49:15 +00:00
|
|
|
;; Disable haskell-stylish on save, it breaks flycheck highlighting
|
|
|
|
'(haskell-stylish-on-save nil))
|
2014-12-02 04:22:45 +00:00
|
|
|
|
2014-12-21 16:03:27 +00:00
|
|
|
;; Make sure company-ghc is properly initialized
|
|
|
|
(autoload 'ghc-init "ghc" nil t)
|
|
|
|
(autoload 'ghc-debug "ghc" nil t)
|
|
|
|
|
2014-12-02 04:22:45 +00:00
|
|
|
(add-hook 'haskell-mode-hook 'haskell-hook)
|
|
|
|
(add-hook 'haskell-cabal-mode-hook 'haskell-cabal-hook)
|
|
|
|
|
2014-12-21 16:03:27 +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)
|
|
|
|
|
|
|
|
;;;;;;;;; Keybindings ;;;;;;;;;;
|
|
|
|
|
|
|
|
;; ;; use "mc" as prefix for cabal commands
|
|
|
|
;; (setq spacemacs/key-binding-prefixes '(("mc" . "cabal")))
|
|
|
|
|
|
|
|
;; ;; use "ms" as prefix for REPL commands
|
|
|
|
;; (setq spacemacs/key-binding-prefixes '(("ms" . "Haskell REPL")))
|
|
|
|
|
|
|
|
;; ;; use "md" as prefix for debug commands
|
|
|
|
;; (setq spacemacs/key-binding-prefixes '(("md" . "Haskell Debug")))
|
|
|
|
|
|
|
|
;; ;; use "mh" as prefix for documentation commands
|
|
|
|
;; (setq spacemacs/key-binding-prefixes '(("mh" . "Haskell Documentation")))
|
|
|
|
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-mode
|
2014-12-22 10:49:15 +00:00
|
|
|
"mt" 'haskell-process-do-type
|
|
|
|
"mi" 'haskell-process-do-info
|
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
|
|
|
|
|
|
|
"mhh" 'hoogle
|
|
|
|
"mhy" 'hayoo
|
|
|
|
"mhd" 'inferior-haskell-find-haddock
|
|
|
|
|
|
|
|
"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
|
|
|
|
"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
|
|
|
|
(evil-leader/set-key-for-mode 'interactive-haskell-mode
|
|
|
|
"msS" 'haskell-interactive-switch
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Compile
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-cabal
|
|
|
|
"mC" 'haskell-compile
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Cabal-file bindings
|
|
|
|
(evil-leader/set-key-for-mode 'haskell-cabal-mode
|
|
|
|
"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
|
|
|
|
"mf" 'haskell-cabal-find-or-create-source-file
|
|
|
|
;; "m=" 'haskell-cabal-subsection-arrange-lines ;; Does a bad job, 'gg=G' works better
|
|
|
|
)
|
|
|
|
|
2014-12-02 04:22:45 +00:00
|
|
|
;; Haskell main editing mode key bindings.
|
|
|
|
(defun haskell-hook ()
|
2015-02-22 12:19:59 +00:00
|
|
|
(ghc-init)
|
2014-12-21 16:03:27 +00:00
|
|
|
;; Use advanced indention
|
2015-02-25 01:04:50 +00:00
|
|
|
(if (not haskell-enable-shm-support)
|
2015-02-23 18:16:47 +00:00
|
|
|
(turn-on-haskell-indentation)
|
|
|
|
)
|
2014-12-02 04:22:45 +00:00
|
|
|
|
|
|
|
;; Indent the below lines on columns after the current column.
|
2014-12-21 16:03:27 +00:00
|
|
|
;; Might need better bindings for spacemacs and OS X
|
2014-12-02 04:22:45 +00:00
|
|
|
(define-key haskell-mode-map (kbd "C-<right>")
|
|
|
|
(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(haskell-move-nested 1)))
|
|
|
|
;; Same as above but backwards.
|
|
|
|
(define-key haskell-mode-map (kbd "C-<left>")
|
|
|
|
(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(haskell-move-nested -1))))
|
|
|
|
|
|
|
|
;; Useful to have these keybindings for .cabal files, too.
|
|
|
|
(defun haskell-cabal-hook ()
|
2015-02-22 11:03:46 +00:00
|
|
|
(define-key haskell-cabal-mode-map [?\C-c ?\C-z] 'haskell-interactive-switch))
|
|
|
|
|
|
|
|
;;GHCi-ng
|
|
|
|
(defun ghci-ng-setup()
|
|
|
|
(progn
|
|
|
|
;; 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
|
|
|
|
"mt" 'haskell-mode-show-type-at
|
|
|
|
"mgg" 'haskell-mode-goto-loc
|
|
|
|
))
|
|
|
|
)
|
|
|
|
|
2015-02-25 01:04:50 +00:00
|
|
|
(if haskell-enable-ghci-ng-support
|
2015-02-22 11:03:46 +00:00
|
|
|
(ghci-ng-setup)))))
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
(defun haskell/init-company-ghc ()
|
2015-02-15 03:45:14 +00:00
|
|
|
(use-package company-ghc
|
|
|
|
:if (configuration-layer/layer-declaredp 'company-mode)
|
|
|
|
:init
|
|
|
|
(progn
|
2015-02-24 13:27:32 +00:00
|
|
|
(add-to-list 'company-backends (company-mode/backend-with-yas 'company-ghc)))))
|
2014-12-30 23:21:48 +00:00
|
|
|
|
|
|
|
(defun haskell/init-hi2 ()
|
|
|
|
(use-package hi2
|
|
|
|
:diminish hi2-mode
|
|
|
|
:commands turn-on-hi2
|
2015-02-25 01:04:50 +00:00
|
|
|
:if (not haskell-enable-shm-support)
|
2014-12-30 23:21:48 +00:00
|
|
|
:init
|
|
|
|
(add-hook 'haskell-mode-hook 'turn-on-hi2)
|
|
|
|
:config
|
|
|
|
(progn
|
2015-01-15 04:23:08 +00:00
|
|
|
|
|
|
|
(defun spacemacs/haskell-show-hi2-guides ()
|
|
|
|
(when (and (boundp 'hi2-mode) hi2-mode)
|
|
|
|
(hi2-enable-show-indentations)))
|
|
|
|
|
|
|
|
(defun spacemacs/haskell-hide-hi2-guides ()
|
|
|
|
(when (and (boundp 'hi2-mode) hi2-mode)
|
|
|
|
(hi2-disable-show-indentations)))
|
|
|
|
|
2014-12-30 23:21:48 +00:00
|
|
|
;; Show indentation guides for hi2 only in insert state.
|
|
|
|
(add-hook 'evil-normal-state-entry-hook 'spacemacs/haskell-hide-hi2-guides)
|
|
|
|
(add-hook 'evil-insert-state-entry-hook 'spacemacs/haskell-show-hi2-guides)
|
|
|
|
(add-hook 'evil-insert-state-exit-hook 'spacemacs/haskell-hide-hi2-guides))))
|