-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-haskell.el
82 lines (58 loc) · 2.57 KB
/
init-haskell.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
(require-package 'haskell-mode)
;; Use intero for completion and flycheck
(when (maybe-require-package 'intero)
(after-load 'haskell-mode
(intero-global-mode)
(add-hook 'haskell-mode-hook 'subword-mode)
(add-hook 'haskell-mode-hook 'eldoc-mode))
(after-load 'haskell-cabal
(add-hook 'haskell-cabal-mode 'subword-mode)
(define-key haskell-cabal-mode-map (kbd "C-c C-l") 'intero-restart))
(after-load 'intero
;; Don't clobber jester/counsel-search-project binding
(define-key intero-mode-map (kbd "M-?") nil)
(after-load 'flycheck
(flycheck-add-next-checker 'intero
'(warning . haskell-hlint)))))
(add-auto-mode 'haskell-mode "\\.ghci\\'")
;; Indentation
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
;; Source code helpers
(add-hook 'haskell-mode-hook 'haskell-auto-insert-module-template)
(when (maybe-require-package 'hindent)
(add-hook 'haskell-mode-hook 'hindent-mode)
(after-load 'hindent
(when (require 'nadvice)
(defun jester/hindent--before-save-wrapper (oldfun &rest args)
(with-demoted-errors "Error invoking hindent: %s"
(let ((debug-on-error nil))
(apply oldfun args))))
(advice-add 'hindent--before-save :around 'jester/hindent--before-save-wrapper))))
(after-load 'haskell-mode
(define-key haskell-mode-map (kbd "C-c h") 'hoogle)
(define-key haskell-mode-map (kbd "C-o") 'open-line))
(after-load 'page-break-lines
(push 'haskell-mode page-break-lines-modes))
(define-minor-mode stack-exec-path-mode
"If this is a stack project, set `exec-path' to the path \"stack exec\" would use."
nil
:lighter ""
:global nil
(if stack-exec-path-mode
(when (and (executable-find "stack")
(locate-dominating-file default-directory "stack.yaml"))
(setq-local
exec-path
(seq-uniq
(append (list (concat (string-trim-right (shell-command-to-string "stack path --local-install-root")) "/bin"))
(parse-colon-path
(replace-regexp-in-string "[\r\n]+\\'" ""
(shell-command-to-string "stack path --bin-path"))))
'string-equal))
;(add-to-list (make-local-variable 'process-environment) (format "PATH=%s" (string-join exec-path path-separator)))
)
(kill-local-variable 'exec-path)))
(add-hook 'haskell-mode-hook 'stack-exec-path-mode)
(when (maybe-require-package 'dhall-mode)
(add-hook 'dhall-mode-hook 'stack-exec-path-mode))
(provide 'init-haskell)