Skip to content

Commit 6d73cf6

Browse files
committed
Use HLS plugins in ghcide
For now there is only one, the main ghcide plugin. But this will allow us to break it down in more fine grained plugins with parallel semantics, both for execution and error handling
1 parent e82f4cd commit 6d73cf6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ghcide/exe/Main.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import Development.IDE.Types.Diagnostics
2828
import Development.IDE.Types.Options
2929
import Development.IDE.Types.Logger
3030
import Development.IDE.Plugin
31-
import Development.IDE.Plugin.Completions as Completions
32-
import Development.IDE.Plugin.CodeAction as CodeAction
3331
import Development.IDE.Plugin.Test as Test
3432
import Development.IDE.Session (loadSession)
3533
import qualified Language.Haskell.LSP.Core as LSP
@@ -54,6 +52,8 @@ import Development.IDE (action)
5452
import Text.Printf
5553
import Development.IDE.Core.Tracing
5654
import Development.IDE.Types.Shake (Key(Key))
55+
import Development.IDE.Plugin.HLS (asGhcIdePlugin)
56+
import Development.IDE.Plugin.HLS.GhcIde as GhcIde
5757
import Ide.Plugin.Config
5858
import Ide.PluginUtils (allLspCmdIds', getProcessID, pluginDescToIdePlugins)
5959

@@ -85,9 +85,14 @@ main = do
8585
whenJust argsCwd IO.setCurrentDirectory
8686

8787
dir <- IO.getCurrentDirectory
88-
command <- makeLspCommandId "typesignature.add"
8988

90-
let plugins = Completions.plugin <> CodeAction.plugin
89+
let hlsPlugins = pluginDescToIdePlugins [GhcIde.descriptor "ghcide"]
90+
91+
pid <- T.pack . show <$> getProcessID
92+
let hlsPlugin = asGhcIdePlugin hlsPlugins
93+
hlsCommands = allLspCmdIds' pid hlsPlugins
94+
95+
let plugins = hlsPlugin
9196
<> if argsTesting then Test.plugin else mempty
9297
onInitialConfiguration :: InitializeRequest -> Either T.Text Config
9398
onInitialConfiguration x = case x ^. params . initializationOptions of
@@ -96,7 +101,7 @@ main = do
96101
J.Error err -> Left $ T.pack err
97102
J.Success a -> Right a
98103
onConfigurationChange = const $ Left "Updating Not supported"
99-
options = def { LSP.executeCommandCommands = Just [command]
104+
options = def { LSP.executeCommandCommands = Just hlsCommands
100105
, LSP.completionTriggerCharacters = Just "."
101106
}
102107

0 commit comments

Comments
 (0)