-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathontop-haskell.el
118 lines (101 loc) · 3.88 KB
/
ontop-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
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
;;; ontop-haskell.el --- Haskell configuration -*- lexical-binding: t; -*-
;; This file is part of Emacs ONTOP
;; https://github.com/monkeyjunglejuice/emacs.ontop
;;; Commentary:
;; You can also use this file/configuration independently from Emacs ONTOP
;; Load it from anywhere via `(load-file "/path/to/ontop-haskell.el")'.
;;; Code:
;; ____________________________________________________________________________
;;; USE-PACKAGE
;; <https://github.com/jwiegley/use-package>
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package nil))
(eval-when-compile
(require 'use-package))
;; ____________________________________________________________________________
;;; HASKELL-MODE
;; <http://haskell.github.io/haskell-mode>
(use-package haskell-mode
:ensure t
:custom
(haskell-completing-read-function 'completing-read)
(haskell-process-auto-import-loaded-modules t)
(haskell-process-suggest-hoogle-imports t)
(haskell-process-suggest-remove-import-lines t)
(haskell-process-type 'auto)
;; Don't use hasktags; the language server provides that functionality
(haskell-tags-on-save nil)
;; Don't use haskell-mode to show docs; the language server will do that
(haskell-doc-show-global-types nil)
(haskell-doc-show-prelude nil)
(haskell-doc-show-reserved nil)
(haskell-doc-show-strategy nil)
(haskell-doc-show-user-defined nil)
:hook
(haskell-mode . interactive-haskell-mode))
(use-package haskell
:ensure nil
:bind
;; Reach REPL from anywhere via global key binding
(:map ctl-z-x-map
("h" . haskell-interactive-bring))
(:map interactive-haskell-mode-map
("C-c C-c" . haskell-compile)
("C-c C-e" . haskell-process-load-file)))
;; ____________________________________________________________________________
;;; EGLOT LANGUAGE SERVER
;; <https://github.com/joaotavora/eglot/blob/master/MANUAL.md>
;; <https://haskell-language-server.readthedocs.io/en/latest/configuration.html>
;; Common keybindings are configured in `./ontop-core.el'
(use-package eglot
:ensure t
:config
(setq-default eglot-workspace-configuration
'((haskell
(formatting-provider . "ormolu")
)))
:custom
;; Shutdown language server after closing last file?
(eglot-autoshutdown t)
;; Allow edits without confirmation?
(eglot-confirm-server-initiated-edits nil)
:hook
;; Start language server automatically when opening a Haskell file?
(haskell-mode . eglot-ensure)
;; Format the buffer before saving?
(haskell-mode . (lambda ()
(add-hook 'before-save-hook
#'eglot-format-buffer t 'local))))
;; ____________________________________________________________________________
;;; PARENTHESIS DISPLAY
;; Rainbow-delimiters color-coding of nested parens is already enabled
;; for all prog-modes in `ontop-core.el'
(use-package rainbow-delimiters
:ensure t
:hook
(interactive-haskell-mode . rainbow-delimiters-mode))
;; Make parens styleable, e.g. more or less prominent
;; <https://github.com/tarsius/paren-face>
;; (use-package paren-face
;; :ensure t
;; :hook
;; ((haskell-mode interactive-haskell-mode) . paren-face-mode))
;; ____________________________________________________________________________
;;; ORG-MODE BABEL
;; <https://org-babel.readthedocs.io/en/latest/eval/>
;; Notebook-like literate programming in Emacs
;; Starts a GHCi REPL in the background
(use-package ob-haskell
:ensure nil)
;; Evaluate Haskell code in Org source code blocks via "C-c C-c"
(use-package org
:ensure nil
:hook
(org-mode . (lambda ()
(org-babel-do-load-languages
'org-babel-load-languages
(add-to-list 'org-babel-load-languages '(haskell . t))))))
;; ____________________________________________________________________________
(provide 'ontop-haskell)
;;; ontop-haskell.el ends here