-
Notifications
You must be signed in to change notification settings - Fork 3
/
packages.el
201 lines (175 loc) · 7.46 KB
/
packages.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
;;; packages.el --- hie layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;;; Code:
(defconst hie-nix-packages
'(
flycheck
(flycheck-haskell :requires flycheck)
nix-sandbox
haskell-mode
(lsp-haskell :requires haskell-mode :location (recipe :fetcher github :repo "emacs-lsp/lsp-haskell"))
))
(defun hie-nix/post-init-flycheck ()
(add-hook 'haskell-mode-hook 'flycheck-mode))
; This doesn't work. Just brings up hippie expand suggestions .
;(defun hie-nix/post-init-company-lsp ()
; (spacemacs|add-company-backends :backend company-lsp :modes haskell-mode))
(defun hie-nix/init-nix-sandbox ()
(use-package nix-sandbox))
(defun hie-nix/init-lsp-haskell ()
(use-package lsp-haskell
:init
(progn
; Some nix shells can be super slow with hie-nix and reflex platform
(setq lsp-response-timeout 30)
(add-hook 'haskell-mode-hook #'lsp))))
(defun hie-nix/init-flycheck-haskell ()
(use-package flycheck-haskell
:commands flycheck-haskell-configure
:init
(progn
(add-hook 'flycheck-mode-hook 'flycheck-haskell-configure)
(when spacemacs/lsp-haskell-nix-wrapped
(setq
lsp-haskell-process-wrapper-function #'hie-nix//default-nix-wrapper
flycheck-command-wrapper-function #'hie-nix//default-nix-wrapper
flycheck-executable-find (lambda (cmd) (nix-executable-find (nix-current-sandbox) cmd))
))
)))
(defun hie-nix/init-haskell-mode ()
(use-package haskell-mode
:defer t
:init
(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)
;; 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 #'hie-nix//disable-electric-indent)
(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
haskell-stylish-on-save nil
haskell-tags-on-save t
)
(when spacemacs/lsp-haskell-nix-wrapped
(setq haskell-process-wrapper-function #'hie-nix//haskell-nix-wrapper))
(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 "me" "haskell/errors")
(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")
(spacemacs/declare-prefix-for-mode mode "mr" "haskell/refactor"))
(spacemacs/declare-prefix-for-mode 'haskell-interactive-mode "ms" "haskell/repl")
(spacemacs/declare-prefix-for-mode 'haskell-cabal-mode "ms" "haskell/repl")
(dolist (mode haskell-modes)
(spacemacs/set-leader-keys-for-major-mode mode
"gi" 'haskell-navigate-imports
"gm" 'lsp-ui-imenu
"gg" 'lsp-ui-peek-find-definitions
"gr" 'lsp-ui-peek-find-references
"F" 'haskell-mode-stylish-buffer
"en" 'flycheck-next-error
"ep" 'flycheck-previous-error
"el" 'flycheck-list-errors
"ee" 'flycheck-explain-error-at-point
"sb" 'haskell-process-load-file
"sc" 'haskell-interactive-mode-clear
"sS" 'spacemacs/haskell-interactive-bring
"ss" 'haskell-interactive-switch
"ca" 'haskell-process-cabal
"cb" 'haskell-process-cabal-build
"cc" 'haskell-compile
"cv" 'haskell-cabal-visit-file
"hd" 'inferior-haskell-find-haddock
"hh" 'hoogle
"hH" 'haskell-hoogle-lookup-from-local
"hi" 'haskell-process-do-info
"ht" 'haskell-process-do-type
;"hT" 'spacemacs/haskell-process-do-type-on-prev-line
"hy" 'hayoo
"da" 'haskell-debug/abandon
"db" 'haskell-debug/break-on-function
"dB" 'haskell-debug/delete
"dc" 'haskell-debug/continue
"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
;;"ri" 'spacemacs/haskell-format-imports
"rR" 'lsp-rename
"rf" 'lsp-format-buffer
"ra" 'lsp-ui-sideline-apply-code-actions
"lr" 'lsp-restart-workspace
"," 'completion-at-point
"." 'lsp-describe-thing-at-point
))
(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
"i" 'haskell-debug/step
"s" 'haskell-debug/next
"S" 'haskell-debug/previous
"r" 'haskell-debug/refresh
"t" 'haskell-debug/trace)
;; configure C-c C-l so it doesn't throw any errors
;; bk: This is crashing things in here. Ignore it till later.
;; (bind-key "C-c C-l" 'haskell-process-load-file haskell-mode-map)
;; Switch back to editor from REPL
(spacemacs/set-leader-keys-for-major-mode 'haskell-interactive-mode
"ss" 'haskell-interactive-switch-back)
;; Compile
(spacemacs/set-leader-keys-for-major-mode 'haskell-cabal
"C" 'haskell-compile)
;; Cabal-file bindings
(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)
;; 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))
))
;;; packages.el ends here