-
Notifications
You must be signed in to change notification settings - Fork 63
/
lsp-haskell.el
738 lines (662 loc) · 30.4 KB
/
lsp-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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
;;; lsp-haskell.el --- Haskell support for lsp-mode -*- lexical-binding: t; -*-
;; Version: 1.1
;; Package-Requires: ((emacs "27.1") (lsp-mode "3.0") (haskell-mode "16.1"))
;; Keywords: haskell
;; URL: https://github.com/emacs-lsp/lsp-haskell
;;; License
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;; Haskell specific adapter for LSP mode
;;; Code:
(require 'lsp-mode)
(require 'haskell-mode)
;; ---------------------------------------------------------------------
;; Configuration
(defgroup lsp-haskell nil
"Customization group for ‘lsp-haskell’."
:group 'lsp-mode)
;; ---------------------------------------------------------------------
;; Language server options
;; These are registered with lsp-mode below, which handles preparing them for the server.
;; Originally generated from the vscode extension's package.json using lsp-generate-bindings.
;; Should ideally stay in sync with what's offered in the vscode extension.
(defcustom-lsp lsp-haskell-formatting-provider
"ormolu"
"The formatter to use when formatting a document or range.
Ensure the plugin is enabled."
:group 'lsp-haskell
:type '(choice (const "brittany") (const "floskell") (const "fourmolu") (const "ormolu") (const "stylish-haskell") (const "none"))
:lsp-path "haskell.formattingProvider")
(defcustom-lsp lsp-haskell-check-project
t
"Whether to typecheck the entire project on load.
It could lead to bad perfomance in large projects."
:group 'lsp-haskell
:type 'boolean
:lsp-path "haskell.checkProject")
(defcustom-lsp lsp-haskell-max-completions
40
"Maximum number of completions sent to the editor."
:group 'lsp-haskell
:type 'number
:lsp-path "haskell.maxCompletions")
(defcustom-lsp lsp-haskell-session-loading
"singleComponent"
"Preferred approach for loading package components. Setting this
to 'multiple components' (EXPERIMENTAL) allows the build
tool (such as `cabal` or `stack`) to load multiple components at
once `https://github.com/haskell/cabal/pull/8726', which is a
significant improvement."
:group 'lsp-haskell
:type '(choice (const "singleComponent") (const "multipleComponents"))
:lsp-path "haskell.sessionLoading")
;; ---------------------------------------------------------------------
;; Plugin-specific configuration
(defgroup lsp-haskell-plugins nil
"Customization group for 'lsp-haskell' plugins."
:group 'lsp-haskell)
(defcustom-lsp lsp-haskell-plugin-import-lens-code-actions-on
t
"Enables explicit imports code actions"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.importLens.codeActionsOn")
(defcustom-lsp lsp-haskell-plugin-import-lens-code-lens-on
t
"Enables explicit imports code lenses"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.importLens.codeLensOn")
(defcustom-lsp lsp-haskell-plugin-hlint-code-actions-on
t
"Enables hlint code actions (apply hints)"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.hlint.codeActionsOn")
(defcustom-lsp lsp-haskell-plugin-hlint-diagnostics-on
t
"Enables hlint diagnostics"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.hlint.diagnosticsOn")
(defcustom-lsp lsp-haskell-plugin-hlint-config-flags
nil
"Flags used by hlint"
:group 'lsp-haskell-plugins
:type 'lsp-string-vector
:lsp-path "haskell.plugin.hlint.config.flags")
(defcustom-lsp lsp-haskell-plugin-eval-global-on
t
"Enables eval plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.eval.globalOn")
(defcustom-lsp lsp-haskell-plugin-module-name-global-on
t
"Enables module name plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.moduleName.globalOn")
(defcustom-lsp lsp-haskell-plugin-splice-global-on
t
"Enables splice plugin (expand template haskell definitions)"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.splice.globalOn")
(defcustom-lsp lsp-haskell-plugin-haddock-comments-global-on
t
"Enables haddock comments plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.haddockComments.globalOn")
(defcustom-lsp lsp-haskell-plugin-class-global-on
t
"Enables type class plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.class.globalOn")
(defcustom-lsp lsp-haskell-plugin-retrie-global-on
t
"Enables retrie plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.retrie.globalOn")
(defcustom-lsp lsp-haskell-plugin-stan-global-on
t
"Enables stan plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.stan.globalOn")
(defcustom-lsp lsp-haskell-plugin-tactics-global-on
t
"Enables Wingman (tactics) plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.tactics.globalOn")
(defcustom-lsp lsp-haskell-plugin-tactics-config-auto-gas
4
"The depth of the search tree when performing \"Attempt to fill hole\".
Bigger values will be able to derive more solutions,
but will take exponentially more time."
:group 'lsp-haskell-plugins
:type 'number
:lsp-path "haskell.plugin.tactics.config.auto_gas")
(defcustom-lsp lsp-haskell-plugin-tactics-config-hole-severity
nil
"The severity to use when showing hole diagnostics."
:group 'lsp-haskell-plugins
:type '(choice (const 1) (const 2) (const 3) (const 4) (const nil))
:lsp-path "haskell.plugin.tactics.config.hole_severity")
(defcustom-lsp lsp-haskell-plugin-tactics-config-max-use-ctor-actions
5
"Maximum number of `Use constructor <x>` code actions that can appear"
:group 'lsp-haskell-plugins
:type 'number
:lsp-path "haskell.plugin.tactics.config.max_use_ctor_actions")
(defcustom-lsp lsp-haskell-plugin-tactics-config-timeout-duration
2
"The timeout for Wingman actions, in seconds"
:group 'lsp-haskell-plugins
:type 'number
:lsp-path "haskell.plugin.tactics.config.timeout_duration")
(defcustom-lsp lsp-haskell-plugin-tactics-config-proofstate-styling
t
"Should Wingman emit styling markup when showing metaprogram proof states?"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.tactics.config.proofstate_styling")
(defcustom-lsp lsp-haskell-plugin-pragmas-code-actions-on
t
"Enables pragmas code actions"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.pragmas.codeActionsOn")
(defcustom-lsp lsp-haskell-plugin-pragmas-completion-on
t
"Enables pragmas completions"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.pragmas.completionsOn")
(defcustom-lsp lsp-haskell-plugin-ghcide-completions-config-auto-extend-on
t
"Extends the import list automatically when completing a out-of-scope identifier"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.ghcide-completions.config.autoExtendOn")
(defcustom-lsp lsp-haskell-plugin-ghcide-completions-config-snippets-on
lsp-enable-snippet
"Inserts snippets when using code completions"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.ghcide-completions.config.snippetsOn")
(defcustom-lsp lsp-haskell-plugin-ghcide-type-lenses-global-on
t
"Enables type lenses plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.ghcide-type-lenses.globalOn")
(defcustom-lsp lsp-haskell-plugin-ghcide-type-lenses-config-mode
t
"Control how type lenses are shown"
:group 'lsp-haskell-plugins
:type '(choice (const "always") (const "exported") (const "diagnostics"))
:lsp-path "haskell.plugin.ghcide-type-lenses.config.mode")
(defcustom-lsp lsp-haskell-plugin-refine-imports-global-on
t
"Enables refine imports plugin"
:group 'lsp-haskell-plugins
:type 'boolean
:lsp-path "haskell.plugin.refineImports.globalOn")
;; Updated for haskell-language-server 2.1.0.0
(lsp-defcustom lsp-haskell-plugin-cabal-code-actions-on t
"Enables cabal code actions"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.cabal.codeActionsOn")
(lsp-defcustom lsp-haskell-plugin-cabal-completion-on t
"Enables cabal completions"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.cabal.completionOn")
(lsp-defcustom lsp-haskell-plugin-pragmas-suggest-global-on t
"Enables pragmas-suggest plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.pragmas-suggest.globalOn")
(lsp-defcustom lsp-haskell-plugin-alternate-number-format-global-on t
"Enables alternateNumberFormat plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.alternateNumberFormat.globalOn")
(lsp-defcustom lsp-haskell-plugin-call-hierarchy-global-on t
"Enables callHierarchy plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.callHierarchy.globalOn")
(lsp-defcustom lsp-haskell-plugin-change-type-signature-global-on t
"Enables changeTypeSignature plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.changeTypeSignature.globalOn")
(lsp-defcustom lsp-haskell-plugin-class-code-actions-on t
"Enables class code actions"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.class.codeActionsOn")
(lsp-defcustom lsp-haskell-plugin-class-code-lens-on t
"Enables class code lenses"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.class.codeLensOn")
(lsp-defcustom lsp-haskell-plugin-eval-config-diff t
"Enable the diff output (WAS/NOW) of eval lenses"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.eval.config.diff")
(lsp-defcustom lsp-haskell-plugin-eval-config-exception nil
"Enable marking exceptions with `*** Exception:` similarly to doctest and GHCi."
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.eval.config.exception")
(lsp-defcustom lsp-haskell-plugin-explicit-fields-global-on t
"Enables explicit-fields plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.explicit-fields.globalOn")
(lsp-defcustom lsp-haskell-plugin-explicit-fixity-global-on t
"Enables explicit-fixity plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.explicit-fixity.globalOn")
(lsp-defcustom lsp-haskell-plugin-fourmolu-config-external nil
"Call out to an external \"fourmolu\" executable, rather than using the bundled library"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.fourmolu.config.external")
(lsp-defcustom lsp-haskell-plugin-gadt-global-on t
"Enables gadt plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.gadt.globalOn")
(lsp-defcustom lsp-haskell-plugin-ghcide-code-actions-bindings-global-on t
"Enables ghcide-code-actions-bindings plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ghcide-code-actions-bindings.globalOn")
(lsp-defcustom lsp-haskell-plugin-ghcide-code-actions-fill-holes-global-on t
"Enables ghcide-code-actions-fill-holes plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ghcide-code-actions-fill-holes.globalOn")
(lsp-defcustom lsp-haskell-plugin-ghcide-code-actions-imports-exports-global-on t
"Enables ghcide-code-actions-imports-exports plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ghcide-code-actions-imports-exports.globalOn")
(lsp-defcustom lsp-haskell-plugin-ghcide-code-actions-type-signatures-global-on t
"Enables ghcide-code-actions-type-signatures plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ghcide-code-actions-type-signatures.globalOn")
(lsp-defcustom lsp-haskell-plugin-ghcide-completions-global-on t
"Enables ghcide-completions plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ghcide-completions.globalOn")
(lsp-defcustom lsp-haskell-plugin-ghcide-hover-and-symbols-hover-on t
"Enables ghcide-hover-and-symbols hover"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ghcide-hover-and-symbols.hoverOn")
(lsp-defcustom lsp-haskell-plugin-ghcide-hover-and-symbols-symbols-on t
"Enables ghcide-hover-and-symbols symbols"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ghcide-hover-and-symbols.symbolsOn")
(lsp-defcustom lsp-haskell-plugin-ormolu-config-external nil
"Call out to an external 'ormolu' executable, rather than using the bundled library"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.ormolu.config.external")
(lsp-defcustom lsp-haskell-plugin-overloaded-record-dot-global-on t
"Enables overloaded-record-dot plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.overloaded-record-dot.globalOn")
(lsp-defcustom lsp-haskell-plugin-pragmas-completion-global-on t
"Enables pragmas-completion plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.pragmas-completion.globalOn")
(lsp-defcustom lsp-haskell-plugin-pragmas-disable-global-on t
"Enables pragmas-disable plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.pragmas-disable.globalOn")
(lsp-defcustom lsp-haskell-plugin-qualify-imported-names-global-on t
"Enables qualifyImportedNames plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.qualifyImportedNames.globalOn")
(lsp-defcustom lsp-haskell-plugin-rename-config-cross-module nil
"Enable experimental cross-module renaming"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.rename.config.crossModule")
(lsp-defcustom lsp-haskell-plugin-rename-global-on t
"Enables rename plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "8.0.1")
:lsp-path "haskell.plugin.rename.globalOn")
;; Updated for haskell-language-server 2.9.0.1
(lsp-defcustom lsp-haskell-plugin-cabal-fmt-config-path "cabal-fmt"
"Set path to 'cabal-fmt' executable"
:type 'string
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.cabal-fmt.config.path")
(lsp-defcustom lsp-haskell-plugin-cabal-gild-config-path "cabal-gild"
"Set path to 'cabal-gild' executable"
:type 'string
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.cabal-gild.config.path")
(lsp-defcustom lsp-haskell-plugin-cabal-diagnostics-on t
"Enables cabal diagnostics"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.cabal.diagnosticsOn")
(lsp-defcustom lsp-haskell-plugin-fourmolu-config-path "fourmolu"
"Set path to executable (for \"external\" mode)."
:type 'string
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.fourmolu.config.path")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-class-method-token
"method"
"LSP semantic token type to use for typeclass methods"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.classMethodToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-class-token
"class"
"LSP semantic token type to use for typeclasses"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.classToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-data-constructor-token
"enumMember"
"LSP semantic token type to use for data constructors"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.dataConstructorToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-function-token
"function"
"LSP semantic token type to use for functions"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.functionToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-module-token
"namespace"
"LSP semantic token type to use for modules"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.moduleToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-operator-token
"operator"
"LSP semantic token type to use for operators"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.operatorToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-pattern-synonym-token
"macro"
"LSP semantic token type to use for pattern synonyms"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.patternSynonymToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-record-field-token
"property"
"LSP semantic token type to use for record fields"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.recordFieldToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-type-constructor-token
"enum"
"LSP semantic token type to use for type constructors"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.typeConstructorToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-type-family-token
"interface"
"LSP semantic token type to use for type families"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.typeFamilyToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-type-synonym-token
"type"
"LSP semantic token type to use for type synonyms"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.typeSynonymToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-type-variable-token
"typeParameter"
"LSP semantic token type to use for type variables"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.typeVariableToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-config-variable-token
"variable"
"LSP semantic token type to use for variables"
:type '(choice (const "namespace") (const "type") (const "class") (const "enum")
(const "interface") (const "struct") (const "typeParameter")
(const "parameter") (const "variable") (const "property") (const "enumMember")
(const "event") (const "function") (const "method") (const "macro")
(const "keyword") (const "modifier") (const "comment") (const "string")
(const "number") (const "regexp") (const "operator") (const "decorator"))
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.config.variableToken")
(lsp-defcustom lsp-haskell-plugin-semantic-tokens-global-on nil
"Enables semanticTokens plugin"
:type 'boolean
:group 'lsp-haskell-plugins
:package-version '(lsp-mode . "9.0.0")
:lsp-path "haskell.plugin.semanticTokens.globalOn")
;; ---------------------------------------------------------------------
;; Non-language server options
(defcustom lsp-haskell-server-path
"haskell-language-server-wrapper"
"The language server executable.
Can be something on the $PATH (e.g. 'ghcide') or a path to an executable itself."
:group 'lsp-haskell
:type 'string)
(defcustom lsp-haskell-server-log-file
(expand-file-name "hls.log" temporary-file-directory)
"The log file used by the server.
Note that this is passed to the server via 'lsp-haskell-server-args', so if
you override that setting then this one will have no effect."
:group 'lsp-haskell
:type 'string)
(defcustom lsp-haskell-server-args
`("-l" ,lsp-haskell-server-log-file)
"The arguments for starting the language server.
For a debug log when using haskell-language-server, use `-d -l /tmp/hls.log'."
:group 'lsp-haskell
:type '(repeat (string :tag "Argument")))
(defcustom lsp-haskell-server-wrapper-function
#'identity
"Use this to wrap the language server process started by lsp-haskell.
For example, use the following the start the process in a nix-shell:
\(lambda (argv)
(append
(append (list \"nix-shell\" \"-I\" \".\" \"--command\" )
(list (mapconcat 'identity argv \" \"))
)
(list (concat (lsp--suggest-project-root) \"/shell.nix\"))
)
)"
:group 'lsp-haskell
:type '(choice
(function-item :tag "None" :value identity)
(function :tag "Custom function")))
;; ---------------------------------------------------------------------
;; Miscellaneous options
;;
(defcustom lsp-haskell-completion-in-comments
t
"Whether to trigger completions in comments.
Note that this must be set to true in order to get completion of pragmas."
:group 'lsp-haskell
:type 'boolean)
;; ---------------------------------------------------------------------
;; Starting the server and registration with lsp-mode
(defun lsp-haskell--server-command ()
"Command and arguments for launching the inferior language server process.
These are assembled from the customizable variables `lsp-haskell-server-path'
and `lsp-haskell-server-args' and `lsp-haskell-server-wrapper-function'."
(funcall lsp-haskell-server-wrapper-function (append (list lsp-haskell-server-path "--lsp") lsp-haskell-server-args) ))
(defun lsp-haskell--action-filter (command)
"lsp-mode transforms JSON false values in code action
arguments to JSON null values when sending the requests back to
the server. We need to explicitly tell it which code action
arguments are non-nullable booleans."
(lsp-fix-code-action-booleans command '(:restrictToOriginatingFile :withSig)))
;; This mapping is set for 'haskell-mode -> haskell' in the lsp-mode repo itself. If we move
;; it there, then delete it from here.
;; It also isn't *too* important: it only sets the language ID, see
;; https://microsoft.github.io/language-server-protocol/specification#textDocumentItem
(add-to-list 'lsp-language-id-configuration '(haskell-literate-mode . "haskell"))
(add-to-list 'lsp-language-id-configuration '(haskell-tng-mode . "haskell"))
(add-to-list 'lsp-language-id-configuration '(haskell-cabal-mode . "haskell"))
(add-to-list 'lsp-language-id-configuration '(haskell-ts-mode . "haskell"))
;; Register the client itself
(lsp-register-client
(make-lsp--client
:new-connection (lsp-stdio-connection (lambda () (lsp-haskell--server-command)))
;; Should run under haskell-mode, haskell-literate-mode and haskell-tng-mode. We need to list haskell-literate-mode even though it's a derived mode of haskell-mode.
:major-modes '(haskell-mode haskell-literate-mode haskell-tng-mode haskell-cabal-mode haskell-ts-mode)
;; This is arbitrary.
:server-id 'lsp-haskell
:synchronize-sections '("haskell")
;; This is somewhat irrelevant, but it is listed in lsp-language-id-configuration, so
;; we should set something consistent here.
:language-id "haskell"
:completion-in-comments? lsp-haskell-completion-in-comments
:action-filter #'lsp-haskell--action-filter
))
;; ---------------------------------------------------------------------
(provide 'lsp-haskell)
;;; lsp-haskell.el ends here