-
-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathHlsPlugins.hs
259 lines (219 loc) · 7.87 KB
/
HlsPlugins.hs
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
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module HlsPlugins where
import Ide.Logger (Pretty (pretty), Recorder,
WithPriority, cmapWithPrio)
import Ide.PluginUtils (pluginDescToIdePlugins)
import Ide.Types (IdePlugins,
PluginId (PluginId))
-- fixed plugins
import Development.IDE (IdeState)
import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde
-- haskell-language-server optional plugins
#if hls_qualifyImportedNames
import qualified Ide.Plugin.QualifyImportedNames as QualifyImportedNames
#endif
#if hls_callHierarchy
import qualified Ide.Plugin.CallHierarchy as CallHierarchy
#endif
#if hls_cabal
import qualified Ide.Plugin.Cabal as Cabal
#endif
#if hls_class
import qualified Ide.Plugin.Class as Class
#endif
#if hls_eval
import qualified Ide.Plugin.Eval as Eval
#endif
#if hls_importLens
import qualified Ide.Plugin.ExplicitImports as ExplicitImports
#endif
#if hls_rename
import qualified Ide.Plugin.Rename as Rename
#endif
#if hls_retrie
import qualified Ide.Plugin.Retrie as Retrie
#endif
#if hls_hlint
import qualified Ide.Plugin.Hlint as Hlint
#endif
#if hls_stan
import qualified Ide.Plugin.Stan as Stan
#endif
#if hls_moduleName
import qualified Ide.Plugin.ModuleName as ModuleName
#endif
#if hls_pragmas
import qualified Ide.Plugin.Pragmas as Pragmas
#endif
#if hls_splice
import qualified Ide.Plugin.Splice as Splice
#endif
#if hls_alternateNumberFormat
import qualified Ide.Plugin.AlternateNumberFormat as AlternateNumberFormat
#endif
#if hls_codeRange
import qualified Ide.Plugin.CodeRange as CodeRange
#endif
#if hls_changeTypeSignature
import qualified Ide.Plugin.ChangeTypeSignature as ChangeTypeSignature
#endif
#if hls_gadt
import qualified Ide.Plugin.GADT as GADT
#endif
#if explicitFixity
import qualified Ide.Plugin.ExplicitFixity as ExplicitFixity
#endif
#if explicitFields
import qualified Ide.Plugin.ExplicitFields as ExplicitFields
#endif
#if hls_overloaded_record_dot
import qualified Ide.Plugin.OverloadedRecordDot as OverloadedRecordDot
#endif
#if hls_notes
import qualified Ide.Plugin.Notes as Notes
#endif
#if hls_cabalProject
import qualified Ide.Plugin.CabalProject as CabalProject
#endif
-- formatters
#if hls_floskell
import qualified Ide.Plugin.Floskell as Floskell
#endif
#if hls_fourmolu
import qualified Ide.Plugin.Fourmolu as Fourmolu
#endif
#if hls_cabalfmt
import qualified Ide.Plugin.CabalFmt as CabalFmt
#endif
#if hls_cabalgild
import qualified Ide.Plugin.CabalGild as CabalGild
#endif
#if hls_ormolu
import qualified Ide.Plugin.Ormolu as Ormolu
#endif
#if hls_stylishHaskell
import qualified Ide.Plugin.StylishHaskell as StylishHaskell
#endif
#if hls_refactor
import qualified Development.IDE.Plugin.CodeAction as Refactor
#endif
#if hls_semanticTokens
import qualified Ide.Plugin.SemanticTokens as SemanticTokens
#endif
data Log = forall a. (Pretty a) => Log PluginId a
instance Pretty Log where
pretty (Log (PluginId pId) a) = pretty pId <> ": " <> pretty a
-- ---------------------------------------------------------------------
-- | The plugins configured for use in this instance of the language
-- server.
-- These can be freely added or removed to tailor the available
-- features of the server.
idePlugins :: Recorder (WithPriority Log) -> IdePlugins IdeState
idePlugins recorder = pluginDescToIdePlugins allPlugins
where
pluginRecorder :: forall log. (Pretty log) => PluginId -> Recorder (WithPriority log)
pluginRecorder pluginId = cmapWithPrio (Log pluginId) recorder
allPlugins =
#if hls_cabal
let pId = "cabal" in Cabal.descriptor (pluginRecorder pId) pId :
let caId = "cabalHaskellIntegration" in Cabal.haskellInteractionDescriptor (pluginRecorder caId) caId :
#endif
#if hls_pragmas
Pragmas.suggestPragmaDescriptor "pragmas-suggest" :
Pragmas.completionDescriptor "pragmas-completion" :
Pragmas.suggestDisableWarningDescriptor "pragmas-disable" :
#endif
#if hls_floskell
Floskell.descriptor "floskell" :
#endif
#if hls_fourmolu
let pId = "fourmolu" in Fourmolu.descriptor (pluginRecorder pId) pId:
#endif
#if hls_cabalfmt
let pId = "cabal-fmt" in CabalFmt.descriptor (pluginRecorder pId) pId:
#endif
#if hls_cabalgild
-- this pId needs to be kept in sync with the hardcoded
-- cabalFormattingProvider in the Default Config
let pId = "cabal-gild" in CabalGild.descriptor (pluginRecorder pId) pId:
#endif
#if hls_ormolu
-- this pId needs to be kept in sync with the hardcoded
-- haskellFormattingProvider in the Default Config
let pId = "ormolu" in Ormolu.descriptor (pluginRecorder pId) pId :
#endif
#if hls_stylishHaskell
let pId = "stylish-haskell" in StylishHaskell.descriptor (pluginRecorder pId) pId :
#endif
#if hls_rename
let pId = "rename" in Rename.descriptor (pluginRecorder pId) pId:
#endif
#if hls_retrie
let pId = "retrie" in Retrie.descriptor (pluginRecorder pId) pId :
#endif
#if hls_callHierarchy
CallHierarchy.descriptor "callHierarchy" :
#endif
#if hls_semanticTokens
let pId = "semanticTokens" in SemanticTokens.descriptor (pluginRecorder pId) pId:
#endif
#if hls_class
let pId = "class" in Class.descriptor (pluginRecorder pId) pId:
#endif
#if hls_eval
let pId = "eval" in Eval.descriptor (pluginRecorder pId) pId:
#endif
#if hls_importLens
let pId = "importLens" in ExplicitImports.descriptor (pluginRecorder pId) pId:
#endif
#if hls_qualifyImportedNames
QualifyImportedNames.descriptor "qualifyImportedNames" :
#endif
#if hls_moduleName
let pId = "moduleName" in ModuleName.descriptor (pluginRecorder pId) pId:
#endif
#if hls_hlint
let pId = "hlint" in Hlint.descriptor (pluginRecorder pId) pId:
#endif
#if hls_stan
let pId = "stan" in Stan.descriptor (pluginRecorder pId) pId :
#endif
#if hls_splice
Splice.descriptor "splice" :
#endif
#if hls_alternateNumberFormat
let pId = "alternateNumberFormat" in AlternateNumberFormat.descriptor (pluginRecorder pId) pId :
#endif
#if hls_codeRange
let pId = "codeRange" in CodeRange.descriptor (pluginRecorder pId) pId:
#endif
#if hls_changeTypeSignature
ChangeTypeSignature.descriptor "changeTypeSignature" :
#endif
#if hls_gadt
GADT.descriptor "gadt" :
#endif
#if hls_refactor
let pId = "ghcide-code-actions-imports-exports" in Refactor.iePluginDescriptor (pluginRecorder pId) pId :
let pId = "ghcide-code-actions-type-signatures" in Refactor.typeSigsPluginDescriptor (pluginRecorder pId) pId :
let pId = "ghcide-code-actions-bindings" in Refactor.bindingsPluginDescriptor (pluginRecorder pId) pId :
let pId = "ghcide-code-actions-fill-holes" in Refactor.fillHolePluginDescriptor (pluginRecorder pId) pId :
let pId = "ghcide-extend-import-action" in Refactor.extendImportPluginDescriptor (pluginRecorder pId) pId :
#endif
#if explicitFixity
let pId = "explicit-fixity" in ExplicitFixity.descriptor (pluginRecorder pId) pId :
#endif
#if explicitFields
let pId = "explicit-fields" in ExplicitFields.descriptor (pluginRecorder pId) pId :
#endif
#if hls_overloaded_record_dot
let pId = "overloaded-record-dot" in OverloadedRecordDot.descriptor (pluginRecorder pId) pId :
#endif
#if hls_notes
let pId = "notes" in Notes.descriptor (pluginRecorder pId) pId :
#endif
#if hls_cabalProject
let pId = "cabal-project" in CabalProject.descriptor (pluginRecorder pId) pId :
#endif
GhcIde.descriptors (pluginRecorder "ghcide")