Skip to content

Commit b7716a4

Browse files
committed
extract haskell-language-server:plugins and let go of examples
The main goal here is to move the Plugins module into an internal library so that it can be reused from the benchmark suite. In order to make that easier, and since they hardly serve a purpose in a repository with 25 plugins, I delete the Example and Example2 plugin descriptors and their dependencies.
1 parent 92d5cf2 commit b7716a4

File tree

4 files changed

+25
-49
lines changed

4 files changed

+25
-49
lines changed

exe/Main.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Development.IDE.Types.Logger (Doc,
2020
payload, renderStrict,
2121
withDefaultRecorder)
2222
import qualified Development.IDE.Types.Logger as Logger
23+
import qualified HlsPlugins as Plugins
2324
import Ide.Arguments (Arguments (..),
2425
GhcideArguments (..),
2526
getArguments)
@@ -31,7 +32,6 @@ import Ide.Types (PluginDescriptor (pluginNotificat
3132
mkPluginNotificationHandler)
3233
import Language.LSP.Server as LSP
3334
import Language.LSP.Types as LSP
34-
import qualified Plugins
3535
#if MIN_VERSION_prettyprinter(1,7,0)
3636
import Prettyprinter (Pretty (pretty), vsep)
3737
#else
@@ -52,7 +52,7 @@ main = do
5252
-- plugin cli commands use stderr logger for now unless we change the args
5353
-- parser to get logging arguments first or do more complicated things
5454
pluginCliRecorder <- cmapWithPrio pretty <$> makeDefaultStderrRecorder Nothing Info
55-
args <- getArguments "haskell-language-server" (Plugins.idePlugins (cmapWithPrio LogPlugins pluginCliRecorder) False)
55+
args <- getArguments "haskell-language-server" (Plugins.idePlugins (cmapWithPrio LogPlugins pluginCliRecorder))
5656

5757
(lspLogRecorder, cb1) <- Logger.withBacklog Logger.lspClientLogRecorder
5858
(lspMessageRecorder, cb2) <- Logger.withBacklog Logger.lspClientMessageRecorder
@@ -64,12 +64,12 @@ main = do
6464
liftIO $ (cb1 <> cb2) env
6565
}
6666

67-
let (argsTesting, minPriority, logFilePath, includeExamplePlugins) =
67+
let (argsTesting, minPriority, logFilePath) =
6868
case args of
69-
Ghcide GhcideArguments{ argsTesting, argsDebugOn, argsLogFile, argsExamplePlugin } ->
69+
Ghcide GhcideArguments{ argsTesting, argsDebugOn, argsLogFile} ->
7070
let minPriority = if argsDebugOn || argsTesting then Debug else Info
71-
in (argsTesting, minPriority, argsLogFile, argsExamplePlugin)
72-
_ -> (False, Info, Nothing, False)
71+
in (argsTesting, minPriority, argsLogFile)
72+
_ -> (False, Info, Nothing)
7373

7474
withDefaultRecorder logFilePath Nothing minPriority $ \textWithPriorityRecorder -> do
7575
let
@@ -87,7 +87,7 @@ main = do
8787
-- ability of lsp-test to detect a stuck server in tests and benchmarks
8888
& if argsTesting then cfilter (not . heapStats . snd . payload) else id
8989
]
90-
plugins = (Plugins.idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins)
90+
plugins = (Plugins.idePlugins (cmapWithPrio LogPlugins recorder))
9191

9292
defaultMain
9393
(cmapWithPrio LogIdeMain recorder)

haskell-language-server.cabal

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,6 @@ flag dynamic
233233
default: True
234234
manual: True
235235

236-
common example-plugins
237-
hs-source-dirs: plugins/default/src
238-
other-modules: Ide.Plugin.Example,
239-
Ide.Plugin.Example2,
240-
Ide.Plugin.ExampleCabal
241-
242236
common class
243237
if flag(class)
244238
build-depends: hls-class-plugin ^>= 1.0
@@ -366,13 +360,12 @@ common brittany
366360
build-depends: hls-brittany-plugin ^>= 1.0
367361
cpp-options: -Dhls_brittany
368362

369-
executable haskell-language-server
363+
library plugins
370364
import: common-deps
371365
-- configuration
372366
, warnings
373367
, pedantic
374368
-- plugins
375-
, example-plugins
376369
, callHierarchy
377370
, changeTypeSignature
378371
, class
@@ -398,10 +391,20 @@ executable haskell-language-server
398391
, ormolu
399392
, stylishHaskell
400393
, brittany
394+
exposed-modules: HlsPlugins
395+
hs-source-dirs: src
396+
397+
build-depends: ghcide, hls-plugin-api
398+
default-language: Haskell2010
399+
default-extensions: DataKinds, TypeOperators
401400

401+
executable haskell-language-server
402+
import: common-deps
403+
-- configuration
404+
, warnings
405+
, pedantic
402406
main-is: Main.hs
403407
hs-source-dirs: exe
404-
other-modules: Plugins
405408

406409
ghc-options:
407410
-threaded
@@ -412,8 +415,6 @@ executable haskell-language-server
412415
-- Enable collection of heap statistics
413416
"-with-rtsopts=-I0 -A128M -T"
414417
-Wno-unticked-promoted-constructors
415-
if flag(pedantic)
416-
ghc-options: -Werror
417418
if !os(windows) && flag(dynamic)
418419
-- We want to link against the dyn rts just like official GHC binaries do;
419420
-- the linked rts determines how external libs are loaded dynamically by TH.
@@ -438,6 +439,7 @@ executable haskell-language-server
438439
, ghcide
439440
, hashable
440441
, haskell-language-server
442+
, haskell-language-server:plugins
441443
, lsp
442444
, hie-bios
443445
, hiedb

exe/Plugins.hs renamed to src/HlsPlugins.hs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE ExistentialQuantification #-}
33
{-# LANGUAGE OverloadedStrings #-}
4-
module Plugins where
4+
module HlsPlugins where
55

66
import Development.IDE.Types.Logger (Pretty (pretty), Recorder,
77
WithPriority, cmapWithPrio)
@@ -11,9 +11,6 @@ import Ide.Types (IdePlugins)
1111
-- fixed plugins
1212
import Development.IDE (IdeState)
1313
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
1714

1815
-- haskell-language-server optional plugins
1916
#if hls_qualifyImportedNames
@@ -130,15 +127,12 @@ instance Pretty Log where
130127
-- These can be freely added or removed to tailor the available
131128
-- features of the server.
132129

133-
idePlugins :: Recorder (WithPriority Log) -> Bool -> IdePlugins IdeState
134-
idePlugins recorder includeExamples = pluginDescToIdePlugins allPlugins
130+
idePlugins :: Recorder (WithPriority Log) -> IdePlugins IdeState
131+
idePlugins recorder = pluginDescToIdePlugins allPlugins
135132
where
136133
pluginRecorder :: forall log. (Pretty log) => Recorder (WithPriority log)
137134
pluginRecorder = cmapWithPrio Log recorder
138-
allPlugins = if includeExamples
139-
then basePlugins ++ examplePlugins
140-
else basePlugins
141-
basePlugins =
135+
allPlugins =
142136
#if hls_pragmas
143137
Pragmas.descriptor "pragmas" :
144138
#endif
@@ -215,9 +209,4 @@ idePlugins recorder includeExamples = pluginDescToIdePlugins allPlugins
215209
#if explicitFixity
216210
++ [ExplicitFixity.descriptor pluginRecorder]
217211
#endif
218-
examplePlugins =
219-
[Example.descriptor pluginRecorder "eg"
220-
,Example2.descriptor pluginRecorder "eg2"
221-
,ExampleCabal.descriptor pluginRecorder "ec"
222-
]
223212

test/functional/Diagnostic.hs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,8 @@ import Test.Hls.Command
1010
-- ---------------------------------------------------------------------
1111

1212
tests :: TestTree
13-
tests = testGroup "diagnostics providers" [
14-
basicTests
15-
, warningTests
16-
]
13+
tests = testGroup "diagnostics providers" [ warningTests ]
1714

18-
basicTests :: TestTree
19-
basicTests = testGroup "Diagnostics work" [
20-
testCase "example plugin produces diagnostics" $
21-
runSession hlsCommandExamplePlugin fullCaps "test/testdata/diagnostics" $ do
22-
doc <- openDoc "Foo.hs" "haskell"
23-
diags <- waitForDiagnosticsFromSource doc "example2"
24-
reduceDiag <- liftIO $ inspectDiagnostic diags ["example2 diagnostic, hello world"]
25-
liftIO $ do
26-
length diags @?= 1
27-
reduceDiag ^. LSP.range @?= Range (Position 0 0) (Position 1 0)
28-
reduceDiag ^. LSP.severity @?= Just DsError
29-
]
3015

3116
warningTests :: TestTree
3217
warningTests = testGroup "Warnings are warnings" [

0 commit comments

Comments
 (0)