Skip to content

Commit 4ea51f6

Browse files
authored
Merge pull request #687 from jneira/cpplugins
Add plugins conditionally at compile time
2 parents e4f677e + 4c57384 commit 4ea51f6

File tree

3 files changed

+292
-90
lines changed

3 files changed

+292
-90
lines changed

exe/Main.hs

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,14 @@
11
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
22
-- SPDX-License-Identifier: Apache-2.0
3-
{-# LANGUAGE CPP #-}
43
{-# LANGUAGE OverloadedStrings #-}
54
{-# LANGUAGE RecordWildCards #-}
65
module Main(main) where
76

87
import Ide.Arguments (Arguments (..), LspArguments (..),
98
getArguments)
109
import Ide.Main (defaultMain)
11-
import Ide.Types (IdePlugins)
10+
import Plugins
1211

13-
-- haskell-language-server plugins
14-
15-
import Ide.Plugin.Eval as Eval
16-
import Ide.Plugin.Example as Example
17-
import Ide.Plugin.Example2 as Example2
18-
import Ide.Plugin.Floskell as Floskell
19-
import Ide.Plugin.Fourmolu as Fourmolu
20-
import Ide.Plugin.GhcIde as GhcIde
21-
import Ide.Plugin.ExplicitImports as ExplicitImports
22-
import Ide.Plugin.Ormolu as Ormolu
23-
import Ide.Plugin.Retrie as Retrie
24-
import Ide.Plugin.StylishHaskell as StylishHaskell
25-
import Ide.Plugin.Tactic as Tactic
26-
import Ide.Plugin.Hlint as Hlint
27-
#if AGPL
28-
import Ide.Plugin.Brittany as Brittany
29-
#endif
30-
import Ide.Plugin (pluginDescToIdePlugins)
31-
import Ide.Plugin.ModuleName as ModuleName
32-
import Ide.Plugin.Pragmas as Pragmas
33-
34-
35-
-- ---------------------------------------------------------------------
36-
37-
-- | The plugins configured for use in this instance of the language
38-
-- server.
39-
-- These can be freely added or removed to tailor the available
40-
-- features of the server.
41-
42-
idePlugins :: Bool -> IdePlugins
43-
idePlugins includeExamples = pluginDescToIdePlugins allPlugins
44-
where
45-
allPlugins = if includeExamples
46-
then basePlugins ++ examplePlugins
47-
else basePlugins
48-
basePlugins =
49-
[ GhcIde.descriptor "ghcide"
50-
, Pragmas.descriptor "pragmas"
51-
, Floskell.descriptor "floskell"
52-
, Fourmolu.descriptor "fourmolu"
53-
, Tactic.descriptor "tactic"
54-
-- , genericDescriptor "generic"
55-
-- , ghcmodDescriptor "ghcmod"
56-
, Ormolu.descriptor "ormolu"
57-
, StylishHaskell.descriptor "stylish-haskell"
58-
, Retrie.descriptor "retrie"
59-
#if AGPL
60-
, Brittany.descriptor "brittany"
61-
#endif
62-
, Eval.descriptor "eval"
63-
, ExplicitImports.descriptor "importLens"
64-
, ModuleName.descriptor "moduleName"
65-
, Hlint.descriptor "hlint"
66-
]
67-
examplePlugins =
68-
[Example.descriptor "eg"
69-
,Example2.descriptor "eg2"
70-
]
71-
72-
-- ---------------------------------------------------------------------
7312

7413
main :: IO ()
7514
main = do

exe/Plugins.hs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE OverloadedStrings #-}
3+
module Plugins where
4+
5+
import Ide.Types (IdePlugins)
6+
import Ide.Plugin (pluginDescToIdePlugins)
7+
8+
-- fixed plugins
9+
import Ide.Plugin.Example as Example
10+
import Ide.Plugin.Example2 as Example2
11+
import Ide.Plugin.GhcIde as GhcIde
12+
13+
-- haskell-language-server optional plugins
14+
15+
#if eval
16+
import Ide.Plugin.Eval as Eval
17+
#endif
18+
19+
#if importLens
20+
import Ide.Plugin.ExplicitImports as ExplicitImports
21+
#endif
22+
23+
#if retrie
24+
import Ide.Plugin.Retrie as Retrie
25+
#endif
26+
27+
#if tactic
28+
import Ide.Plugin.Tactic as Tactic
29+
#endif
30+
31+
#if hlint
32+
import Ide.Plugin.Hlint as Hlint
33+
#endif
34+
35+
#if moduleName
36+
import Ide.Plugin.ModuleName as ModuleName
37+
#endif
38+
39+
#if pragmas
40+
import Ide.Plugin.Pragmas as Pragmas
41+
#endif
42+
43+
-- formatters
44+
45+
#if floskell
46+
import Ide.Plugin.Floskell as Floskell
47+
#endif
48+
49+
#if fourmolu
50+
import Ide.Plugin.Fourmolu as Fourmolu
51+
#endif
52+
53+
#if ormolu
54+
import Ide.Plugin.Ormolu as Ormolu
55+
#endif
56+
57+
#if stylishHaskell
58+
import Ide.Plugin.StylishHaskell as StylishHaskell
59+
#endif
60+
61+
#if AGPL && brittany
62+
import Ide.Plugin.Brittany as Brittany
63+
#endif
64+
65+
-- ---------------------------------------------------------------------
66+
67+
-- | The plugins configured for use in this instance of the language
68+
-- server.
69+
-- These can be freely added or removed to tailor the available
70+
-- features of the server.
71+
72+
idePlugins :: Bool -> IdePlugins
73+
idePlugins includeExamples = pluginDescToIdePlugins allPlugins
74+
where
75+
allPlugins = if includeExamples
76+
then basePlugins ++ examplePlugins
77+
else basePlugins
78+
basePlugins =
79+
[ GhcIde.descriptor "ghcide"
80+
#if pragmas
81+
, Pragmas.descriptor "pragmas"
82+
#endif
83+
#if floskell
84+
, Floskell.descriptor "floskell"
85+
#endif
86+
#if fourmolu
87+
, Fourmolu.descriptor "fourmolu"
88+
#endif
89+
#if tactic
90+
, Tactic.descriptor "tactic"
91+
#endif
92+
#if ormolu
93+
, Ormolu.descriptor "ormolu"
94+
#endif
95+
#if stylishHaskell
96+
, StylishHaskell.descriptor "stylish-haskell"
97+
#endif
98+
#if retrie
99+
, Retrie.descriptor "retrie"
100+
#endif
101+
#if AGPL && brittany
102+
, Brittany.descriptor "brittany"
103+
#endif
104+
#if eval
105+
, Eval.descriptor "eval"
106+
#endif
107+
#if importLens
108+
, ExplicitImports.descriptor "importLens"
109+
#endif
110+
#if moduleName
111+
, ModuleName.descriptor "moduleName"
112+
#endif
113+
#if hlint
114+
, Hlint.descriptor "hlint"
115+
#endif
116+
]
117+
examplePlugins =
118+
[Example.descriptor "eg"
119+
,Example2.descriptor "eg2"
120+
]

0 commit comments

Comments
 (0)