diff --git a/exe/Plugins.hs b/exe/Plugins.hs index 1bd2336e9c..69d98d0866 100644 --- a/exe/Plugins.hs +++ b/exe/Plugins.hs @@ -10,6 +10,7 @@ import Ide.Plugin.Example as Example import Ide.Plugin.Example2 as Example2 import Development.IDE (IdeState) import Development.IDE.Plugin.HLS.GhcIde as GhcIde +import Development.IDE.Plugin.HLS.Completions as Completions -- haskell-language-server optional plugins @@ -81,7 +82,8 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins then basePlugins ++ examplePlugins else basePlugins basePlugins = - [ GhcIde.descriptor "ghcide" + [ GhcIde.descriptor "ghcide", + Completions.descriptor "completions" #if pragmas , Pragmas.descriptor "pragmas" #endif diff --git a/ghcide/exe/Main.hs b/ghcide/exe/Main.hs index 5a3adfd546..1837e9b847 100644 --- a/ghcide/exe/Main.hs +++ b/ghcide/exe/Main.hs @@ -54,6 +54,7 @@ import Development.IDE.Core.Tracing import Development.IDE.Types.Shake (Key(Key)) import Development.IDE.Plugin.HLS (asGhcIdePlugin) import Development.IDE.Plugin.HLS.GhcIde as GhcIde +import Development.IDE.Plugin.HLS.Completions as Completions import Ide.Plugin.Config import Ide.PluginUtils (allLspCmdIds', getProcessID, pluginDescToIdePlugins) @@ -86,7 +87,7 @@ main = do dir <- IO.getCurrentDirectory - let hlsPlugins = pluginDescToIdePlugins [GhcIde.descriptor "ghcide"] + let hlsPlugins = pluginDescToIdePlugins [GhcIde.descriptor "ghcide", Completions.descriptor "completions"] pid <- T.pack . show <$> getProcessID let hlsPlugin = asGhcIdePlugin hlsPlugins diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index ec1d42774a..046898b67c 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -166,6 +166,7 @@ library Development.IDE.Plugin.CodeAction Development.IDE.Plugin.HLS Development.IDE.Plugin.HLS.GhcIde + Development.IDE.Plugin.HLS.Completions Development.IDE.Plugin.Test -- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses diff --git a/ghcide/src/Development/IDE/Plugin/HLS/Completions.hs b/ghcide/src/Development/IDE/Plugin/HLS/Completions.hs new file mode 100644 index 0000000000..80df40432f --- /dev/null +++ b/ghcide/src/Development/IDE/Plugin/HLS/Completions.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE OverloadedStrings #-} + +-- | Exposes the ghcide features as an HLS plugin +module Development.IDE.Plugin.HLS.Completions + ( + descriptor + ) where + +import Data.Aeson +import Development.IDE +import Development.IDE.Plugin as Ghcide +import Development.IDE.Plugin.Completions as Completions +import Ide.PluginUtils +import Ide.Types +import Language.Haskell.LSP.Types +import Text.Regex.TDFA.Text() + +-- --------------------------------------------------------------------- + +descriptor :: PluginId -> PluginDescriptor IdeState +descriptor plId = (defaultPluginDescriptor plId) + { pluginCommands = [] + , pluginCodeActionProvider = Nothing + , pluginCodeLensProvider = Nothing + , pluginHoverProvider = Nothing + , pluginSymbolsProvider = Nothing + , pluginCompletionProvider = Just getCompletionsLSP + , pluginRules = Ghcide.pluginRules Completions.plugin + } diff --git a/ghcide/src/Development/IDE/Plugin/HLS/GhcIde.hs b/ghcide/src/Development/IDE/Plugin/HLS/GhcIde.hs index dfcc6e72ed..5108ae5cfc 100644 --- a/ghcide/src/Development/IDE/Plugin/HLS/GhcIde.hs +++ b/ghcide/src/Development/IDE/Plugin/HLS/GhcIde.hs @@ -28,8 +28,8 @@ descriptor plId = (defaultPluginDescriptor plId) , pluginCodeLensProvider = Just codeLens' , pluginHoverProvider = Just hover' , pluginSymbolsProvider = Just symbolsProvider - , pluginCompletionProvider = Just getCompletionsLSP - , pluginRules = Ghcide.pluginRules Completions.plugin <> Ghcide.pluginRules CodeAction.plugin + , pluginCompletionProvider = Nothing + , pluginRules = Ghcide.pluginRules CodeAction.plugin } -- ---------------------------------------------------------------------