Skip to content

Commit 20dbeea

Browse files
committed
Support haskell-literate-mode
This just requires a few extra settings.
1 parent 485427a commit 20dbeea

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ this repository, or install from MELPA. Add the following to your `.emacs`:
1919
```emacs-lisp
2020
(require 'lsp)
2121
(require 'lsp-haskell)
22+
;; Hooks so haskell and literate haskell major modes trigger LSP setup
2223
(add-hook 'haskell-mode-hook #'lsp)
24+
(add-hook 'haskell-literate-mode-hook #'lsp)
2325
```
2426

2527
Note: All three packages are also available via MELPA.

lsp-haskell.el

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,29 @@ and `lsp-haskell-server-args'."
233233
("haskell.maxNumberOfProblems" lsp-haskell-max-number-of-problems)
234234
("haskell.hlintOn" lsp-haskell-hlint-on t)))
235235

236+
;; This mapping is set for 'haskell-mode -> haskell' in the lsp-mode repo itself. If we move
237+
;; it there, then delete it from here.
238+
;; It also isn't *too* important: it only sets the language ID, see
239+
;; https://microsoft.github.io/language-server-protocol/specification#textDocumentItem
240+
(add-to-list 'lsp-language-id-configuration '(haskell-literate-mode . "haskell"))
241+
236242
;; Register the client itself
237243
(lsp-register-client
238244
(make-lsp--client
239245
:new-connection (lsp-stdio-connection (lambda () (lsp-haskell--server-command)))
240-
:major-modes '(haskell-mode)
246+
;; Should run under haskell-mode and haskell-literate-mode. We need to list the
247+
;; latter even though it's a derived mode of the former
248+
:major-modes '(haskell-mode haskell-literate-mode)
241249
;; This is arbitrary.
242250
:server-id 'lsp-haskell
243251
;; We need to manually pull out the configuration section and set it. Possibly in
244252
;; the future lsp-mode will asssociate servers with configuration sections more directly.
245253
:initialized-fn (lambda (workspace)
246254
(with-lsp-workspace workspace
247255
(lsp--set-configuration (lsp-configuration-section "haskell"))))
248-
;; No need to set :language-id, since there isn't one for Haskell and we
249-
;; don't support multiple languages
256+
;; This is somewhat irrelevant, but it is listed in lsp-language-id-configuration, so
257+
;; we should set something consistent here.
258+
:language-id "haskell"
250259
))
251260

252261
;; ---------------------------------------------------------------------

0 commit comments

Comments
 (0)