|
| 1 | +{-# LANGUAGE CPP #-} |
| 2 | +{-# LANGUAGE ExistentialQuantification #-} |
| 3 | +{-# LANGUAGE OverloadedStrings #-} |
| 4 | +module Plugins where |
| 5 | + |
| 6 | +import Development.IDE.Types.Logger (Pretty (pretty), Recorder, |
| 7 | + WithPriority, cmapWithPrio) |
| 8 | +import Ide.PluginUtils (pluginDescToIdePlugins) |
| 9 | +import Ide.Types (IdePlugins) |
| 10 | + |
| 11 | +-- fixed plugins |
| 12 | +import Development.IDE (IdeState) |
| 13 | +import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde |
| 14 | +import qualified Ide.Plugin.Example as Example |
| 15 | +import qualified Ide.Plugin.Example2 as Example2 |
| 16 | +import qualified Ide.Plugin.ExampleCabal as ExampleCabal |
| 17 | + |
| 18 | +-- haskell-language-server optional plugins |
| 19 | +#if qualifyImportedNames |
| 20 | +import qualified Ide.Plugin.QualifyImportedNames as QualifyImportedNames |
| 21 | +#endif |
| 22 | + |
| 23 | +#if callHierarchy |
| 24 | +import qualified Ide.Plugin.CallHierarchy as CallHierarchy |
| 25 | +#endif |
| 26 | + |
| 27 | +#if class |
| 28 | +import qualified Ide.Plugin.Class as Class |
| 29 | +#endif |
| 30 | + |
| 31 | +#if haddockComments |
| 32 | +import qualified Ide.Plugin.HaddockComments as HaddockComments |
| 33 | +#endif |
| 34 | + |
| 35 | +#if eval |
| 36 | +import qualified Ide.Plugin.Eval as Eval |
| 37 | +#endif |
| 38 | + |
| 39 | +#if importLens |
| 40 | +import qualified Ide.Plugin.ExplicitImports as ExplicitImports |
| 41 | +#endif |
| 42 | + |
| 43 | +#if refineImports |
| 44 | +import qualified Ide.Plugin.RefineImports as RefineImports |
| 45 | +#endif |
| 46 | + |
| 47 | +#if rename |
| 48 | +import qualified Ide.Plugin.Rename as Rename |
| 49 | +#endif |
| 50 | + |
| 51 | +#if retrie |
| 52 | +import qualified Ide.Plugin.Retrie as Retrie |
| 53 | +#endif |
| 54 | + |
| 55 | +#if tactic |
| 56 | +import qualified Ide.Plugin.Tactic as Tactic |
| 57 | +#endif |
| 58 | + |
| 59 | +#if hlint |
| 60 | +import qualified Ide.Plugin.Hlint as Hlint |
| 61 | +#endif |
| 62 | + |
| 63 | +#if moduleName |
| 64 | +import qualified Ide.Plugin.ModuleName as ModuleName |
| 65 | +#endif |
| 66 | + |
| 67 | +#if pragmas |
| 68 | +import qualified Ide.Plugin.Pragmas as Pragmas |
| 69 | +#endif |
| 70 | + |
| 71 | +#if splice |
| 72 | +import qualified Ide.Plugin.Splice as Splice |
| 73 | +#endif |
| 74 | + |
| 75 | +#if alternateNumberFormat |
| 76 | +import qualified Ide.Plugin.AlternateNumberFormat as AlternateNumberFormat |
| 77 | +#endif |
| 78 | + |
| 79 | +#if selectionRange |
| 80 | +import Ide.Plugin.SelectionRange as SelectionRange |
| 81 | +#endif |
| 82 | + |
| 83 | +#if changeTypeSignature |
| 84 | +import Ide.Plugin.ChangeTypeSignature as ChangeTypeSignature |
| 85 | +#endif |
| 86 | + |
| 87 | +#if gadt |
| 88 | +import Ide.Plugin.GADT as GADT |
| 89 | +#endif |
| 90 | +-- formatters |
| 91 | + |
| 92 | +#if floskell |
| 93 | +import qualified Ide.Plugin.Floskell as Floskell |
| 94 | +#endif |
| 95 | + |
| 96 | +#if fourmolu |
| 97 | +import qualified Ide.Plugin.Fourmolu as Fourmolu |
| 98 | +#endif |
| 99 | + |
| 100 | +#if ormolu |
| 101 | +import qualified Ide.Plugin.Ormolu as Ormolu |
| 102 | +#endif |
| 103 | + |
| 104 | +#if stylishHaskell |
| 105 | +import qualified Ide.Plugin.StylishHaskell as StylishHaskell |
| 106 | +#endif |
| 107 | + |
| 108 | +#if brittany |
| 109 | +import qualified Ide.Plugin.Brittany as Brittany |
| 110 | +#endif |
| 111 | + |
| 112 | +#if cabalfmt |
| 113 | +import qualified Ide.Plugin.CabalFmt as CabalFmt |
| 114 | +#endif |
| 115 | + |
| 116 | +data Log = forall a. (Pretty a) => Log a |
| 117 | + |
| 118 | +instance Pretty Log where |
| 119 | + pretty (Log a) = pretty a |
| 120 | + |
| 121 | +-- --------------------------------------------------------------------- |
| 122 | + |
| 123 | +-- | The plugins configured for use in this instance of the language |
| 124 | +-- server. |
| 125 | +-- These can be freely added or removed to tailor the available |
| 126 | +-- features of the server. |
| 127 | + |
| 128 | +idePlugins :: Recorder (WithPriority Log) -> Bool -> IdePlugins IdeState |
| 129 | +idePlugins recorder includeExamples = pluginDescToIdePlugins allPlugins |
| 130 | + where |
| 131 | + pluginRecorder :: forall log. (Pretty log) => Recorder (WithPriority log) |
| 132 | + pluginRecorder = cmapWithPrio Log recorder |
| 133 | + allPlugins = if includeExamples |
| 134 | + then basePlugins ++ examplePlugins |
| 135 | + else basePlugins |
| 136 | + basePlugins = |
| 137 | +#if pragmas |
| 138 | + Pragmas.descriptor "pragmas" : |
| 139 | +#endif |
| 140 | +#if floskell |
| 141 | + Floskell.descriptor "floskell" : |
| 142 | +#endif |
| 143 | +#if fourmolu |
| 144 | + Fourmolu.descriptor pluginRecorder "fourmolu" : |
| 145 | +#endif |
| 146 | +#if tactic |
| 147 | + Tactic.descriptor pluginRecorder "tactics" : |
| 148 | +#endif |
| 149 | +#if ormolu |
| 150 | + Ormolu.descriptor "ormolu" : |
| 151 | +#endif |
| 152 | +#if stylishHaskell |
| 153 | + StylishHaskell.descriptor "stylish-haskell" : |
| 154 | +#endif |
| 155 | +#if rename |
| 156 | + Rename.descriptor "rename" : |
| 157 | +#endif |
| 158 | +#if retrie |
| 159 | + Retrie.descriptor "retrie" : |
| 160 | +#endif |
| 161 | +#if brittany |
| 162 | + Brittany.descriptor "brittany" : |
| 163 | +#endif |
| 164 | +#if cabalfmt |
| 165 | + CabalFmt.descriptor pluginRecorder "cabal-fmt" : |
| 166 | +#endif |
| 167 | +#if callHierarchy |
| 168 | + CallHierarchy.descriptor : |
| 169 | +#endif |
| 170 | +#if class |
| 171 | + Class.descriptor pluginRecorder "class" : |
| 172 | +#endif |
| 173 | +#if haddockComments |
| 174 | + HaddockComments.descriptor "haddockComments" : |
| 175 | +#endif |
| 176 | +#if eval |
| 177 | + Eval.descriptor pluginRecorder "eval" : |
| 178 | +#endif |
| 179 | +#if importLens |
| 180 | + ExplicitImports.descriptor pluginRecorder "importLens" : |
| 181 | +#endif |
| 182 | +#if qualifyImportedNames |
| 183 | + QualifyImportedNames.descriptor "qualifyImportedNames" : |
| 184 | +#endif |
| 185 | +#if refineImports |
| 186 | + RefineImports.descriptor pluginRecorder "refineImports" : |
| 187 | +#endif |
| 188 | +#if moduleName |
| 189 | + ModuleName.descriptor "moduleName" : |
| 190 | +#endif |
| 191 | +#if hlint |
| 192 | + Hlint.descriptor pluginRecorder "hlint" : |
| 193 | +#endif |
| 194 | +#if splice |
| 195 | + Splice.descriptor "splice" : |
| 196 | +#endif |
| 197 | +#if alternateNumberFormat |
| 198 | + AlternateNumberFormat.descriptor pluginRecorder : |
| 199 | +#endif |
| 200 | +#if selectionRange |
| 201 | + SelectionRange.descriptor "selectionRange" : |
| 202 | +#endif |
| 203 | +#if changeTypeSignature |
| 204 | + ChangeTypeSignature.descriptor : |
| 205 | +#endif |
| 206 | +#if gadt |
| 207 | + GADT.descriptor "gadt" : |
| 208 | +#endif |
| 209 | + -- The ghcide descriptors should come last so that the notification handlers |
| 210 | + -- (which restart the Shake build) run after everything else |
| 211 | + GhcIde.descriptors pluginRecorder |
| 212 | + examplePlugins = |
| 213 | + [Example.descriptor pluginRecorder "eg" |
| 214 | + ,Example2.descriptor pluginRecorder "eg2" |
| 215 | + ,ExampleCabal.descriptor pluginRecorder "ec" |
| 216 | + ] |
0 commit comments