Skip to content

Commit 7cf6494

Browse files
authored
Merge pull request #148 from michaelpj/mpj/defcustom-lsp
Switch to using defcustom-lsp
2 parents 69ddd5d + 23dece1 commit 7cf6494

File tree

1 file changed

+85
-88
lines changed

1 file changed

+85
-88
lines changed

lsp-haskell.el

Lines changed: 85 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -44,148 +44,175 @@
4444
;; Originally generated from the vscode extension's package.json using lsp-generate-bindings.
4545
;; Should ideally stay in sync with what's offered in the vscode extension.
4646

47-
(defcustom lsp-haskell-formatting-provider
47+
(defcustom-lsp lsp-haskell-formatting-provider
4848
"ormolu"
4949
"The formatter to use when formatting a document or range. Ensure the plugin is enabled."
5050
:group 'lsp-haskell
51-
:type '(choice (const "brittany") (const "floskell") (const "fourmolu") (const "ormolu") (const "stylish-haskell") (const "none")))
52-
(defcustom lsp-haskell-check-project
51+
:type '(choice (const "brittany") (const "floskell") (const "fourmolu") (const "ormolu") (const "stylish-haskell") (const "none"))
52+
:lsp-path "haskell.formattingProvider")
53+
(defcustom-lsp lsp-haskell-check-project
5354
t
5455
"Whether to typecheck the entire project on load. It could lead to bad perfomance in large projects."
5556
:group 'lsp-haskell
56-
:type 'boolean)
57-
(defcustom lsp-haskell-max-completions
57+
:type 'boolean
58+
:lsp-path "haskell.checkProject")
59+
(defcustom-lsp lsp-haskell-max-completions
5860
40
5961
"Maximum number of completions sent to the editor."
6062
:group 'lsp-haskell
61-
:type 'number)
63+
:type 'number
64+
:lsp-path "haskell.maxCompletions")
6265

6366
;; ---------------------------------------------------------------------
6467
;; Plugin-specific configuration
6568
(defgroup lsp-haskell-plugins nil
6669
"Customization group for 'lsp-haskell' plugins."
6770
:group 'lsp-haskell)
6871

69-
(defcustom lsp-haskell-plugin-import-lens-code-actions-on
72+
(defcustom-lsp lsp-haskell-plugin-import-lens-code-actions-on
7073
t
7174
"Enables explicit imports code actions"
7275
:group 'lsp-haskell-plugins
73-
:type 'boolean)
74-
(defcustom lsp-haskell-plugin-import-lens-code-lens-on
76+
:type 'boolean
77+
:lsp-path "haskell.plugin.importLens.codeActionsOn")
78+
(defcustom-lsp lsp-haskell-plugin-import-lens-code-lens-on
7579
t
7680
"Enables explicit imports code lenses"
7781
:group 'lsp-haskell-plugins
78-
:type 'boolean)
79-
(defcustom lsp-haskell-plugin-hlint-code-actions-on
82+
:type 'boolean
83+
:lsp-path "haskell.plugin.importLens.codeLensOn")
84+
(defcustom-lsp lsp-haskell-plugin-hlint-code-actions-on
8085
t
8186
"Enables hlint code actions (apply hints)"
8287
:group 'lsp-haskell-plugins
83-
:type 'boolean)
84-
(defcustom lsp-haskell-plugin-hlint-diagnostics-on
88+
:type 'boolean
89+
:lsp-path "haskell.plugin.hlint.codeActionsOn")
90+
(defcustom-lsp lsp-haskell-plugin-hlint-diagnostics-on
8591
t
8692
"Enables hlint diagnostics"
8793
:group 'lsp-haskell-plugins
88-
:type 'boolean)
89-
(defcustom lsp-haskell-plugin-hlint-config-flags
94+
:type 'boolean
95+
:lsp-path "haskell.plugin.hlint.diagnosticsOn")
96+
(defcustom-lsp lsp-haskell-plugin-hlint-config-flags
9097
nil
9198
"Flags used by hlint"
9299
:group 'lsp-haskell-plugins
93-
:type 'lsp-string-vector)
94-
(defcustom lsp-haskell-plugin-eval-global-on
100+
:type 'lsp-string-vector
101+
:lsp-path "haskell.plugin.hlint.config.flags")
102+
(defcustom-lsp lsp-haskell-plugin-eval-global-on
95103
t
96104
"Enables eval plugin"
97105
:group 'lsp-haskell-plugins
98-
:type 'boolean)
99-
(defcustom lsp-haskell-plugin-module-name-global-on
106+
:type 'boolean
107+
:lsp-path "haskell.plugin.eval.globalOn")
108+
(defcustom-lsp lsp-haskell-plugin-module-name-global-on
100109
t
101110
"Enables module name plugin"
102111
:group 'lsp-haskell-plugins
103-
:type 'boolean)
104-
(defcustom lsp-haskell-plugin-splice-global-on
112+
:type 'boolean
113+
:lsp-path "haskell.plugin.moduleName.globalOn")
114+
(defcustom-lsp lsp-haskell-plugin-splice-global-on
105115
t
106116
"Enables splice plugin (expand template haskell definitions)"
107117
:group 'lsp-haskell-plugins
108-
:type 'boolean)
109-
(defcustom lsp-haskell-plugin-haddock-comments-global-on
118+
:type 'boolean
119+
:lsp-path "haskell.plugin.splice.globalOn")
120+
(defcustom-lsp lsp-haskell-plugin-haddock-comments-global-on
110121
t
111122
"Enables haddock comments plugin"
112123
:group 'lsp-haskell-plugins
113-
:type 'boolean)
114-
(defcustom lsp-haskell-plugin-class-global-on
124+
:type 'boolean
125+
:lsp-path "haskell.plugin.haddockComments.globalOn")
126+
(defcustom-lsp lsp-haskell-plugin-class-global-on
115127
t
116128
"Enables type class plugin"
117129
:group 'lsp-haskell-plugins
118-
:type 'boolean)
119-
(defcustom lsp-haskell-plugin-retrie-global-on
130+
:type 'boolean
131+
:lsp-path "haskell.plugin.class.globalOn")
132+
(defcustom-lsp lsp-haskell-plugin-retrie-global-on
120133
t
121134
"Enables retrie plugin"
122135
:group 'lsp-haskell-plugins
123-
:type 'boolean)
124-
(defcustom lsp-haskell-plugin-tactics-global-on
136+
:type 'boolean
137+
:lsp-path "haskell.plugin.retrie.globalOn")
138+
(defcustom-lsp lsp-haskell-plugin-tactics-global-on
125139
t
126140
"Enables Wingman (tactics) plugin"
127141
:group 'lsp-haskell-plugins
128-
:type 'boolean)
129-
(defcustom lsp-haskell-plugin-tactics-config-auto-gas
142+
:type 'boolean
143+
:lsp-path "haskell.plugin.tactics.globalOn")
144+
(defcustom-lsp lsp-haskell-plugin-tactics-config-auto-gas
130145
4
131146
"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."
132147
:group 'lsp-haskell-plugins
133-
:type 'number)
134-
(defcustom lsp-haskell-plugin-tactics-config-hole-severity
148+
:type 'number
149+
:lsp-path "haskell.plugin.tactics.config.auto_gas")
150+
(defcustom-lsp lsp-haskell-plugin-tactics-config-hole-severity
135151
nil
136152
"The severity to use when showing hole diagnostics."
137153
:group 'lsp-haskell-plugins
138-
:type '(choice (const 1) (const 2) (const 3) (const 4) (const nil)))
139-
(defcustom lsp-haskell-plugin-tactics-config-max-use-ctor-actions
154+
:type '(choice (const 1) (const 2) (const 3) (const 4) (const nil))
155+
:lsp-path "haskell.plugin.tactics.config.hole_severity")
156+
(defcustom-lsp lsp-haskell-plugin-tactics-config-max-use-ctor-actions
140157
5
141158
"Maximum number of `Use constructor <x>` code actions that can appear"
142159
:group 'lsp-haskell-plugins
143-
:type 'number)
144-
(defcustom lsp-haskell-plugin-tactics-config-timeout-duration
160+
:type 'number
161+
:lsp-path "haskell.plugin.tactics.config.max_use_ctor_actions")
162+
(defcustom-lsp lsp-haskell-plugin-tactics-config-timeout-duration
145163
2
146164
"The timeout for Wingman actions, in seconds"
147165
:group 'lsp-haskell-plugins
148-
:type 'number)
149-
(defcustom lsp-haskell-plugin-tactics-config-proofstate-styling
166+
:type 'number
167+
:lsp-path "haskell.plugin.tactics.config.timeout_duration")
168+
(defcustom-lsp lsp-haskell-plugin-tactics-config-proofstate-styling
150169
t
151170
"Should Wingman emit styling markup when showing metaprogram proof states?"
152171
:group 'lsp-haskell-plugins
153-
:type 'boolean)
154-
(defcustom lsp-haskell-plugin-pragmas-code-actions-on
172+
:type 'boolean
173+
:lsp-path "haskell.plugin.tactics.config.proofstate_styling")
174+
(defcustom-lsp lsp-haskell-plugin-pragmas-code-actions-on
155175
t
156176
"Enables pragmas code actions"
157177
:group 'lsp-haskell-plugins
158-
:type 'boolean)
159-
(defcustom lsp-haskell-plugin-pragmas-completion-on
178+
:type 'boolean
179+
:lsp-path "haskell.plugin.pragmas.codeActionsOn")
180+
(defcustom-lsp lsp-haskell-plugin-pragmas-completion-on
160181
t
161182
"Enables pragmas completions"
162183
:group 'lsp-haskell-plugins
163-
:type 'boolean)
164-
(defcustom lsp-haskell-plugin-ghcide-completions-config-auto-extend-on
184+
:type 'boolean
185+
:lsp-path "haskell.plugin.pragmas.completionsOn")
186+
(defcustom-lsp lsp-haskell-plugin-ghcide-completions-config-auto-extend-on
165187
t
166188
"Extends the import list automatically when completing a out-of-scope identifier"
167189
:group 'lsp-haskell-plugins
168-
:type 'boolean)
169-
(defcustom lsp-haskell-plugin-ghcide-completions-config-snippets-on
190+
:type 'boolean
191+
:lsp-path "haskell.plugin.ghcide-completions.config.autoExtendOn")
192+
(defcustom-lsp lsp-haskell-plugin-ghcide-completions-config-snippets-on
170193
lsp-enable-snippet
171194
"Inserts snippets when using code completions"
172195
:group 'lsp-haskell-plugins
173-
:type 'boolean)
174-
(defcustom lsp-haskell-plugin-ghcide-type-lenses-global-on
196+
:type 'boolean
197+
:lsp-path "haskell.plugin.ghcide-completions.config.snippetsOn")
198+
(defcustom-lsp lsp-haskell-plugin-ghcide-type-lenses-global-on
175199
t
176200
"Enables type lenses plugin"
177201
:group 'lsp-haskell-plugins
178-
:type 'boolean)
179-
(defcustom lsp-haskell-plugin-ghcide-type-lenses-config-mode
202+
:type 'boolean
203+
:lsp-path "haskell.plugin.ghcide-type-lenses.globalOn")
204+
(defcustom-lsp lsp-haskell-plugin-ghcide-type-lenses-config-mode
180205
t
181206
"Control how type lenses are shown"
182207
:group 'lsp-haskell-plugins
183-
:type '(choice (const "always") (const "exported") (const "diagnostics")))
184-
(defcustom lsp-haskell-plugin-refine-imports-global-on
208+
:type '(choice (const "always") (const "exported") (const "diagnostics"))
209+
:lsp-path "haskell.plugin.ghcide-type-lenses.config.mode")
210+
(defcustom-lsp lsp-haskell-plugin-refine-imports-global-on
185211
t
186212
"Enables refine imports plugin"
187213
:group 'lsp-haskell-plugins
188-
:type 'boolean)
214+
:type 'boolean
215+
:lsp-path "haskell.plugin.refineImports.globalOn")
189216

190217
;; ---------------------------------------------------------------------
191218
;; Non-language server options
@@ -248,38 +275,6 @@ These are assembled from the customizable variables `lsp-haskell-server-path'
248275
and `lsp-haskell-server-args' and `lsp-haskell-server-wrapper-function'."
249276
(funcall lsp-haskell-server-wrapper-function (append (list lsp-haskell-server-path "--lsp") lsp-haskell-server-args) ))
250277

251-
;; Register all the language server settings with lsp-mode.
252-
;; Note that customizing these will currently *not* send the updated configuration to the server,
253-
;; users must manually restart. See https://github.com/emacs-lsp/lsp-mode/issues/1174.
254-
(lsp-register-custom-settings
255-
'(("haskell.plugin.refineImports.globalOn" lsp-haskell-plugin-refine-imports-global-on t)
256-
("haskell.plugin.ghcide-type-lenses.config.mode" lsp-haskell-plugin-ghcide-type-lenses-config-mode)
257-
("haskell.plugin.ghcide-type-lenses.globalOn" lsp-haskell-plugin-ghcide-type-lenses-global-on t)
258-
("haskell.plugin.ghcide-completions.config.snippetsOn" lsp-haskell-plugin-ghcide-completions-config-snippets-on t)
259-
("haskell.plugin.ghcide-completions.config.autoExtendOn" lsp-haskell-plugin-ghcide-completions-config-auto-extend-on t)
260-
("haskell.plugin.pragmas.completionOn" lsp-haskell-plugin-pragmas-completion-on t)
261-
("haskell.plugin.pragmas.codeActionsOn" lsp-haskell-plugin-pragmas-code-actions-on t)
262-
("haskell.plugin.tactics.config.proofstate_styling" lsp-haskell-plugin-tactics-config-proofstate-styling t)
263-
("haskell.plugin.tactics.config.timeout_duration" lsp-haskell-plugin-tactics-config-timeout-duration)
264-
("haskell.plugin.tactics.config.max_use_ctor_actions" lsp-haskell-plugin-tactics-config-max-use-ctor-actions)
265-
("haskell.plugin.tactics.config.hole_severity" lsp-haskell-plugin-tactics-config-hole-severity)
266-
("haskell.plugin.tactics.config.auto_gas" lsp-haskell-plugin-tactics-config-auto-gas)
267-
("haskell.plugin.tactics.globalOn" lsp-haskell-plugin-tactics-global-on t)
268-
("haskell.plugin.retrie.globalOn" lsp-haskell-plugin-retrie-global-on t)
269-
("haskell.plugin.class.globalOn" lsp-haskell-plugin-class-global-on t)
270-
("haskell.plugin.haddockComments.globalOn" lsp-haskell-plugin-haddock-comments-global-on t)
271-
("haskell.plugin.splice.globalOn" lsp-haskell-plugin-splice-global-on t)
272-
("haskell.plugin.moduleName.globalOn" lsp-haskell-plugin-module-name-global-on t)
273-
("haskell.plugin.eval.globalOn" lsp-haskell-plugin-eval-global-on t)
274-
("haskell.plugin.hlint.config.flags" lsp-haskell-plugin-hlint-config-flags)
275-
("haskell.plugin.hlint.diagnosticsOn" lsp-haskell-plugin-hlint-diagnostics-on t)
276-
("haskell.plugin.hlint.codeActionsOn" lsp-haskell-plugin-hlint-code-actions-on t)
277-
("haskell.plugin.importLens.codeLensOn" lsp-haskell-plugin-import-lens-code-lens-on t)
278-
("haskell.plugin.importLens.codeActionsOn" lsp-haskell-plugin-import-lens-code-actions-on t)
279-
("haskell.maxCompletions" lsp-haskell-max-completions)
280-
("haskell.checkProject" lsp-haskell-check-project t)
281-
("haskell.formattingProvider" lsp-haskell-formatting-provider)))
282-
283278
;; This mapping is set for 'haskell-mode -> haskell' in the lsp-mode repo itself. If we move
284279
;; it there, then delete it from here.
285280
;; It also isn't *too* important: it only sets the language ID, see
@@ -295,11 +290,13 @@ and `lsp-haskell-server-args' and `lsp-haskell-server-wrapper-function'."
295290
:major-modes '(haskell-mode haskell-literate-mode haskell-tng-mode)
296291
;; This is arbitrary.
297292
:server-id 'lsp-haskell
298-
;; We need to manually pull out the configuration section and set it. Possibly in
299-
;; the future lsp-mode will asssociate servers with configuration sections more directly.
293+
;; HLS does not currently send 'workspace/configuration' on startup (https://github.com/haskell/haskell-language-server/issues/2762),
294+
;; so we need to push the configuration to it manually on startup. We should be able to
295+
;; get rid of this once the issue is fixed in HLS.
300296
:initialized-fn (lambda (workspace)
301297
(with-lsp-workspace workspace
302298
(lsp--set-configuration (lsp-configuration-section "haskell"))))
299+
:synchronize-sections '("haskell")
303300
;; This is somewhat irrelevant, but it is listed in lsp-language-id-configuration, so
304301
;; we should set something consistent here.
305302
:language-id "haskell"

0 commit comments

Comments
 (0)