Skip to content

Commit 23dece1

Browse files
committed
Switch to using defcustom-lsp
This means that changing the settings will send `didChangeConfiguration` notifications to running servers, so you shouldn't have to restart the server to see the different configuration.
1 parent 6ffc681 commit 23dece1

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
@@ -46,148 +46,175 @@
4646
;; Originally generated from the vscode extension's package.json using lsp-generate-bindings.
4747
;; Should ideally stay in sync with what's offered in the vscode extension.
4848

49-
(defcustom lsp-haskell-formatting-provider
49+
(defcustom-lsp lsp-haskell-formatting-provider
5050
"ormolu"
5151
"The formatter to use when formatting a document or range. Ensure the plugin is enabled."
5252
:group 'lsp-haskell
53-
:type '(choice (const "brittany") (const "floskell") (const "fourmolu") (const "ormolu") (const "stylish-haskell") (const "none")))
54-
(defcustom lsp-haskell-check-project
53+
:type '(choice (const "brittany") (const "floskell") (const "fourmolu") (const "ormolu") (const "stylish-haskell") (const "none"))
54+
:lsp-path "haskell.formattingProvider")
55+
(defcustom-lsp lsp-haskell-check-project
5556
t
5657
"Whether to typecheck the entire project on load. It could lead to bad perfomance in large projects."
5758
:group 'lsp-haskell
58-
:type 'boolean)
59-
(defcustom lsp-haskell-max-completions
59+
:type 'boolean
60+
:lsp-path "haskell.checkProject")
61+
(defcustom-lsp lsp-haskell-max-completions
6062
40
6163
"Maximum number of completions sent to the editor."
6264
:group 'lsp-haskell
63-
:type 'number)
65+
:type 'number
66+
:lsp-path "haskell.maxCompletions")
6467

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

71-
(defcustom lsp-haskell-plugin-import-lens-code-actions-on
74+
(defcustom-lsp lsp-haskell-plugin-import-lens-code-actions-on
7275
t
7376
"Enables explicit imports code actions"
7477
:group 'lsp-haskell-plugins
75-
:type 'boolean)
76-
(defcustom lsp-haskell-plugin-import-lens-code-lens-on
78+
:type 'boolean
79+
:lsp-path "haskell.plugin.importLens.codeActionsOn")
80+
(defcustom-lsp lsp-haskell-plugin-import-lens-code-lens-on
7781
t
7882
"Enables explicit imports code lenses"
7983
:group 'lsp-haskell-plugins
80-
:type 'boolean)
81-
(defcustom lsp-haskell-plugin-hlint-code-actions-on
84+
:type 'boolean
85+
:lsp-path "haskell.plugin.importLens.codeLensOn")
86+
(defcustom-lsp lsp-haskell-plugin-hlint-code-actions-on
8287
t
8388
"Enables hlint code actions (apply hints)"
8489
:group 'lsp-haskell-plugins
85-
:type 'boolean)
86-
(defcustom lsp-haskell-plugin-hlint-diagnostics-on
90+
:type 'boolean
91+
:lsp-path "haskell.plugin.hlint.codeActionsOn")
92+
(defcustom-lsp lsp-haskell-plugin-hlint-diagnostics-on
8793
t
8894
"Enables hlint diagnostics"
8995
:group 'lsp-haskell-plugins
90-
:type 'boolean)
91-
(defcustom lsp-haskell-plugin-hlint-config-flags
96+
:type 'boolean
97+
:lsp-path "haskell.plugin.hlint.diagnosticsOn")
98+
(defcustom-lsp lsp-haskell-plugin-hlint-config-flags
9299
nil
93100
"Flags used by hlint"
94101
:group 'lsp-haskell-plugins
95-
:type 'lsp-string-vector)
96-
(defcustom lsp-haskell-plugin-eval-global-on
102+
:type 'lsp-string-vector
103+
:lsp-path "haskell.plugin.hlint.config.flags")
104+
(defcustom-lsp lsp-haskell-plugin-eval-global-on
97105
t
98106
"Enables eval plugin"
99107
:group 'lsp-haskell-plugins
100-
:type 'boolean)
101-
(defcustom lsp-haskell-plugin-module-name-global-on
108+
:type 'boolean
109+
:lsp-path "haskell.plugin.eval.globalOn")
110+
(defcustom-lsp lsp-haskell-plugin-module-name-global-on
102111
t
103112
"Enables module name plugin"
104113
:group 'lsp-haskell-plugins
105-
:type 'boolean)
106-
(defcustom lsp-haskell-plugin-splice-global-on
114+
:type 'boolean
115+
:lsp-path "haskell.plugin.moduleName.globalOn")
116+
(defcustom-lsp lsp-haskell-plugin-splice-global-on
107117
t
108118
"Enables splice plugin (expand template haskell definitions)"
109119
:group 'lsp-haskell-plugins
110-
:type 'boolean)
111-
(defcustom lsp-haskell-plugin-haddock-comments-global-on
120+
:type 'boolean
121+
:lsp-path "haskell.plugin.splice.globalOn")
122+
(defcustom-lsp lsp-haskell-plugin-haddock-comments-global-on
112123
t
113124
"Enables haddock comments plugin"
114125
:group 'lsp-haskell-plugins
115-
:type 'boolean)
116-
(defcustom lsp-haskell-plugin-class-global-on
126+
:type 'boolean
127+
:lsp-path "haskell.plugin.haddockComments.globalOn")
128+
(defcustom-lsp lsp-haskell-plugin-class-global-on
117129
t
118130
"Enables type class plugin"
119131
:group 'lsp-haskell-plugins
120-
:type 'boolean)
121-
(defcustom lsp-haskell-plugin-retrie-global-on
132+
:type 'boolean
133+
:lsp-path "haskell.plugin.class.globalOn")
134+
(defcustom-lsp lsp-haskell-plugin-retrie-global-on
122135
t
123136
"Enables retrie plugin"
124137
:group 'lsp-haskell-plugins
125-
:type 'boolean)
126-
(defcustom lsp-haskell-plugin-tactics-global-on
138+
:type 'boolean
139+
:lsp-path "haskell.plugin.retrie.globalOn")
140+
(defcustom-lsp lsp-haskell-plugin-tactics-global-on
127141
t
128142
"Enables Wingman (tactics) plugin"
129143
:group 'lsp-haskell-plugins
130-
:type 'boolean)
131-
(defcustom lsp-haskell-plugin-tactics-config-auto-gas
144+
:type 'boolean
145+
:lsp-path "haskell.plugin.tactics.globalOn")
146+
(defcustom-lsp lsp-haskell-plugin-tactics-config-auto-gas
132147
4
133148
"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."
134149
:group 'lsp-haskell-plugins
135-
:type 'number)
136-
(defcustom lsp-haskell-plugin-tactics-config-hole-severity
150+
:type 'number
151+
:lsp-path "haskell.plugin.tactics.config.auto_gas")
152+
(defcustom-lsp lsp-haskell-plugin-tactics-config-hole-severity
137153
nil
138154
"The severity to use when showing hole diagnostics."
139155
:group 'lsp-haskell-plugins
140-
:type '(choice (const 1) (const 2) (const 3) (const 4) (const nil)))
141-
(defcustom lsp-haskell-plugin-tactics-config-max-use-ctor-actions
156+
:type '(choice (const 1) (const 2) (const 3) (const 4) (const nil))
157+
:lsp-path "haskell.plugin.tactics.config.hole_severity")
158+
(defcustom-lsp lsp-haskell-plugin-tactics-config-max-use-ctor-actions
142159
5
143160
"Maximum number of `Use constructor <x>` code actions that can appear"
144161
:group 'lsp-haskell-plugins
145-
:type 'number)
146-
(defcustom lsp-haskell-plugin-tactics-config-timeout-duration
162+
:type 'number
163+
:lsp-path "haskell.plugin.tactics.config.max_use_ctor_actions")
164+
(defcustom-lsp lsp-haskell-plugin-tactics-config-timeout-duration
147165
2
148166
"The timeout for Wingman actions, in seconds"
149167
:group 'lsp-haskell-plugins
150-
:type 'number)
151-
(defcustom lsp-haskell-plugin-tactics-config-proofstate-styling
168+
:type 'number
169+
:lsp-path "haskell.plugin.tactics.config.timeout_duration")
170+
(defcustom-lsp lsp-haskell-plugin-tactics-config-proofstate-styling
152171
t
153172
"Should Wingman emit styling markup when showing metaprogram proof states?"
154173
:group 'lsp-haskell-plugins
155-
:type 'boolean)
156-
(defcustom lsp-haskell-plugin-pragmas-code-actions-on
174+
:type 'boolean
175+
:lsp-path "haskell.plugin.tactics.config.proofstate_styling")
176+
(defcustom-lsp lsp-haskell-plugin-pragmas-code-actions-on
157177
t
158178
"Enables pragmas code actions"
159179
:group 'lsp-haskell-plugins
160-
:type 'boolean)
161-
(defcustom lsp-haskell-plugin-pragmas-completion-on
180+
:type 'boolean
181+
:lsp-path "haskell.plugin.pragmas.codeActionsOn")
182+
(defcustom-lsp lsp-haskell-plugin-pragmas-completion-on
162183
t
163184
"Enables pragmas completions"
164185
:group 'lsp-haskell-plugins
165-
:type 'boolean)
166-
(defcustom lsp-haskell-plugin-ghcide-completions-config-auto-extend-on
186+
:type 'boolean
187+
:lsp-path "haskell.plugin.pragmas.completionsOn")
188+
(defcustom-lsp lsp-haskell-plugin-ghcide-completions-config-auto-extend-on
167189
t
168190
"Extends the import list automatically when completing a out-of-scope identifier"
169191
:group 'lsp-haskell-plugins
170-
:type 'boolean)
171-
(defcustom lsp-haskell-plugin-ghcide-completions-config-snippets-on
192+
:type 'boolean
193+
:lsp-path "haskell.plugin.ghcide-completions.config.autoExtendOn")
194+
(defcustom-lsp lsp-haskell-plugin-ghcide-completions-config-snippets-on
172195
lsp-enable-snippet
173196
"Inserts snippets when using code completions"
174197
:group 'lsp-haskell-plugins
175-
:type 'boolean)
176-
(defcustom lsp-haskell-plugin-ghcide-type-lenses-global-on
198+
:type 'boolean
199+
:lsp-path "haskell.plugin.ghcide-completions.config.snippetsOn")
200+
(defcustom-lsp lsp-haskell-plugin-ghcide-type-lenses-global-on
177201
t
178202
"Enables type lenses plugin"
179203
:group 'lsp-haskell-plugins
180-
:type 'boolean)
181-
(defcustom lsp-haskell-plugin-ghcide-type-lenses-config-mode
204+
:type 'boolean
205+
:lsp-path "haskell.plugin.ghcide-type-lenses.globalOn")
206+
(defcustom-lsp lsp-haskell-plugin-ghcide-type-lenses-config-mode
182207
t
183208
"Control how type lenses are shown"
184209
:group 'lsp-haskell-plugins
185-
:type '(choice (const "always") (const "exported") (const "diagnostics")))
186-
(defcustom lsp-haskell-plugin-refine-imports-global-on
210+
:type '(choice (const "always") (const "exported") (const "diagnostics"))
211+
:lsp-path "haskell.plugin.ghcide-type-lenses.config.mode")
212+
(defcustom-lsp lsp-haskell-plugin-refine-imports-global-on
187213
t
188214
"Enables refine imports plugin"
189215
:group 'lsp-haskell-plugins
190-
:type 'boolean)
216+
:type 'boolean
217+
:lsp-path "haskell.plugin.refineImports.globalOn")
191218

192219
;; ---------------------------------------------------------------------
193220
;; Non-language server options
@@ -276,38 +303,6 @@ These are assembled from the customizable variables `lsp-haskell-server-path'
276303
and `lsp-haskell-server-args' and `lsp-haskell-server-wrapper-function'."
277304
(funcall lsp-haskell-server-wrapper-function (append (list lsp-haskell-server-path "--lsp") lsp-haskell-server-args) ))
278305

279-
;; Register all the language server settings with lsp-mode.
280-
;; Note that customizing these will currently *not* send the updated configuration to the server,
281-
;; users must manually restart. See https://github.com/emacs-lsp/lsp-mode/issues/1174.
282-
(lsp-register-custom-settings
283-
'(("haskell.plugin.refineImports.globalOn" lsp-haskell-plugin-refine-imports-global-on t)
284-
("haskell.plugin.ghcide-type-lenses.config.mode" lsp-haskell-plugin-ghcide-type-lenses-config-mode)
285-
("haskell.plugin.ghcide-type-lenses.globalOn" lsp-haskell-plugin-ghcide-type-lenses-global-on t)
286-
("haskell.plugin.ghcide-completions.config.snippetsOn" lsp-haskell-plugin-ghcide-completions-config-snippets-on t)
287-
("haskell.plugin.ghcide-completions.config.autoExtendOn" lsp-haskell-plugin-ghcide-completions-config-auto-extend-on t)
288-
("haskell.plugin.pragmas.completionOn" lsp-haskell-plugin-pragmas-completion-on t)
289-
("haskell.plugin.pragmas.codeActionsOn" lsp-haskell-plugin-pragmas-code-actions-on t)
290-
("haskell.plugin.tactics.config.proofstate_styling" lsp-haskell-plugin-tactics-config-proofstate-styling t)
291-
("haskell.plugin.tactics.config.timeout_duration" lsp-haskell-plugin-tactics-config-timeout-duration)
292-
("haskell.plugin.tactics.config.max_use_ctor_actions" lsp-haskell-plugin-tactics-config-max-use-ctor-actions)
293-
("haskell.plugin.tactics.config.hole_severity" lsp-haskell-plugin-tactics-config-hole-severity)
294-
("haskell.plugin.tactics.config.auto_gas" lsp-haskell-plugin-tactics-config-auto-gas)
295-
("haskell.plugin.tactics.globalOn" lsp-haskell-plugin-tactics-global-on t)
296-
("haskell.plugin.retrie.globalOn" lsp-haskell-plugin-retrie-global-on t)
297-
("haskell.plugin.class.globalOn" lsp-haskell-plugin-class-global-on t)
298-
("haskell.plugin.haddockComments.globalOn" lsp-haskell-plugin-haddock-comments-global-on t)
299-
("haskell.plugin.splice.globalOn" lsp-haskell-plugin-splice-global-on t)
300-
("haskell.plugin.moduleName.globalOn" lsp-haskell-plugin-module-name-global-on t)
301-
("haskell.plugin.eval.globalOn" lsp-haskell-plugin-eval-global-on t)
302-
("haskell.plugin.hlint.config.flags" lsp-haskell-plugin-hlint-config-flags)
303-
("haskell.plugin.hlint.diagnosticsOn" lsp-haskell-plugin-hlint-diagnostics-on t)
304-
("haskell.plugin.hlint.codeActionsOn" lsp-haskell-plugin-hlint-code-actions-on t)
305-
("haskell.plugin.importLens.codeLensOn" lsp-haskell-plugin-import-lens-code-lens-on t)
306-
("haskell.plugin.importLens.codeActionsOn" lsp-haskell-plugin-import-lens-code-actions-on t)
307-
("haskell.maxCompletions" lsp-haskell-max-completions)
308-
("haskell.checkProject" lsp-haskell-check-project t)
309-
("haskell.formattingProvider" lsp-haskell-formatting-provider)))
310-
311306
;; This mapping is set for 'haskell-mode -> haskell' in the lsp-mode repo itself. If we move
312307
;; it there, then delete it from here.
313308
;; It also isn't *too* important: it only sets the language ID, see
@@ -323,11 +318,13 @@ and `lsp-haskell-server-args' and `lsp-haskell-server-wrapper-function'."
323318
:major-modes '(haskell-mode haskell-literate-mode)
324319
;; This is arbitrary.
325320
:server-id 'lsp-haskell
326-
;; We need to manually pull out the configuration section and set it. Possibly in
327-
;; the future lsp-mode will asssociate servers with configuration sections more directly.
321+
;; HLS does not currently send 'workspace/configuration' on startup (https://github.com/haskell/haskell-language-server/issues/2762),
322+
;; so we need to push the configuration to it manually on startup. We should be able to
323+
;; get rid of this once the issue is fixed in HLS.
328324
:initialized-fn (lambda (workspace)
329325
(with-lsp-workspace workspace
330326
(lsp--set-configuration (lsp-configuration-section "haskell"))))
327+
:synchronize-sections '("haskell")
331328
;; This is somewhat irrelevant, but it is listed in lsp-language-id-configuration, so
332329
;; we should set something consistent here.
333330
:language-id "haskell"

0 commit comments

Comments
 (0)