From b8f2241ff14848677ddcf20925b68d0b75ef3480 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Wed, 18 Mar 2020 23:08:41 +0000 Subject: [PATCH 1/5] Create plugin for wrapping the handlers from ghcide The way PartialHandlers are chained in ghcide means earlier ones get masked by ones added later in the chain. Create GhcIde plugin so the underlying hover handler can be combined with other configured hover handlers at the haskell-language-server combined handler. Requires https://github.com/digital-asset/ghcide/pull/490 --- .gitmodules | 4 ++-- exe/Main.hs | 11 +++++++++-- ghcide | 2 +- haskell-language-server.cabal | 1 + src/Ide/Plugin.hs | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index f7d6551110..7faeadd5ea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,5 +10,5 @@ # rm -rf path_to_submodule [submodule "ghcide"] path = ghcide - url = https://github.com/digital-asset/ghcide.git - # url = https://github.com/alanz/ghcide.git + # url = https://github.com/digital-asset/ghcide.git + url = https://github.com/alanz/ghcide.git diff --git a/exe/Main.hs b/exe/Main.hs index 816c321f2b..439a1be19b 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -58,15 +58,20 @@ import System.Log.Logger as L import System.Time.Extra -- --------------------------------------------------------------------- - +-- ghcide partialhandlers import Development.IDE.Plugin.CodeAction as CodeAction import Development.IDE.Plugin.Completions as Completions +import Development.IDE.LSP.HoverDefinition as HoverDefinition + + -- haskell-language-server plugins import Ide.Plugin.Example as Example import Ide.Plugin.Example2 as Example2 +import Ide.Plugin.GhcIde as GhcIde import Ide.Plugin.Floskell as Floskell import Ide.Plugin.Ormolu as Ormolu import Ide.Plugin.Pragmas as Pragmas + -- --------------------------------------------------------------------- -- | The plugins configured for use in this instance of the language @@ -90,7 +95,8 @@ idePlugins pid includeExamples -- , hsimportDescriptor "hsimport" -- , liquidDescriptor "liquid" -- , packageDescriptor "package" - Pragmas.descriptor "pragmas" + GhcIde.descriptor "ghc" + , Pragmas.descriptor "pragmas" , Floskell.descriptor "floskell" -- , genericDescriptor "generic" -- , ghcmodDescriptor "ghcmod" @@ -145,6 +151,7 @@ main = do -- (ps, commandIds) = idePlugins pid argsExamplePlugin (ps, commandIds) = idePlugins pid True plugins = Completions.plugin <> CodeAction.plugin <> + Plugin mempty HoverDefinition.setHandlersDefinition <> ps options = def { LSP.executeCommandCommands = Just commandIds , LSP.completionTriggerCharacters = Just "." diff --git a/ghcide b/ghcide index 8b328bb7c5..a5c95baa54 160000 --- a/ghcide +++ b/ghcide @@ -1 +1 @@ -Subproject commit 8b328bb7c5f3e09280788b56abd6fb6d0bfb08ce +Subproject commit a5c95baa54f6c8d2cdd3910fa10efae533c1e0ff diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index a3076a8af3..97b7ecd69a 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -34,6 +34,7 @@ library Ide.Plugin.Config Ide.Plugin.Example Ide.Plugin.Example2 + Ide.Plugin.GhcIde Ide.Plugin.Ormolu Ide.Plugin.Pragmas Ide.Plugin.Floskell diff --git a/src/Ide/Plugin.hs b/src/Ide/Plugin.hs index 2f1a36498f..1d2b4c6db1 100644 --- a/src/Ide/Plugin.hs +++ b/src/Ide/Plugin.hs @@ -40,6 +40,7 @@ import Ide.Plugin.Config import Ide.Plugin.Formatter import Ide.Types import qualified Language.Haskell.LSP.Core as LSP +import qualified Language.Haskell.LSP.Messages as LSP import Language.Haskell.LSP.Messages import Language.Haskell.LSP.Types import qualified Language.Haskell.LSP.Types as J From daf98d759335e8abb3a75b0b5f91b7fde197f5d0 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Wed, 18 Mar 2020 23:20:59 +0000 Subject: [PATCH 2/5] Remove unused import, so tests can run --- src/Ide/Plugin.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Ide/Plugin.hs b/src/Ide/Plugin.hs index 1d2b4c6db1..2f1a36498f 100644 --- a/src/Ide/Plugin.hs +++ b/src/Ide/Plugin.hs @@ -40,7 +40,6 @@ import Ide.Plugin.Config import Ide.Plugin.Formatter import Ide.Types import qualified Language.Haskell.LSP.Core as LSP -import qualified Language.Haskell.LSP.Messages as LSP import Language.Haskell.LSP.Messages import Language.Haskell.LSP.Types import qualified Language.Haskell.LSP.Types as J From 0b4b6ef34704e1861be6d05aee6f28a3714b06f0 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 19 Mar 2020 18:33:31 +0000 Subject: [PATCH 3/5] Switch back to ghcide master --- .gitmodules | 4 ++-- ghcide | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 7faeadd5ea..f7d6551110 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,5 +10,5 @@ # rm -rf path_to_submodule [submodule "ghcide"] path = ghcide - # url = https://github.com/digital-asset/ghcide.git - url = https://github.com/alanz/ghcide.git + url = https://github.com/digital-asset/ghcide.git + # url = https://github.com/alanz/ghcide.git diff --git a/ghcide b/ghcide index a5c95baa54..7ecdd21874 160000 --- a/ghcide +++ b/ghcide @@ -1 +1 @@ -Subproject commit a5c95baa54f6c8d2cdd3910fa10efae533c1e0ff +Subproject commit 7ecdd21874e1b9c638502c47d61facd3be581c65 From 07e73f504f29dca6b1ed86fd9b92809bd338d25b Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 19 Mar 2020 20:36:21 +0000 Subject: [PATCH 4/5] CI: Build cabal deps in a separate step, use new-build. --- .circleci/config.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 70b984260b..53aca2c977 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -148,13 +148,21 @@ jobs: - cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }} - run: name: Update - command: cabal update + command: cabal new-update - run: name: Configure - command: cabal configure --enable-tests + command: cabal new-configure --enable-tests + - run: + name: Build dependencies + command: cabal new-build -j1 --dependencies-only # need j1, else ghc-lib-parser triggers OOM + no_output_timeout: 30m + - save_cache: + key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }} + paths: + - ~/.cabal - run: name: Build - command: cabal build -j1 # need j1, else ghc-lib-parser triggers OOM + command: cabal new-build -j1 # need j1, else ghc-lib-parser triggers OOM no_output_timeout: 30m - save_cache: key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }} From 8299f251964d324fa9c3bb885969b808bff2a91b Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 19 Mar 2020 20:54:16 +0000 Subject: [PATCH 5/5] Add missing source file. Duh. --- src/Ide/Plugin/GhcIde.hs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Ide/Plugin/GhcIde.hs diff --git a/src/Ide/Plugin/GhcIde.hs b/src/Ide/Plugin/GhcIde.hs new file mode 100644 index 0000000000..16826956d7 --- /dev/null +++ b/src/Ide/Plugin/GhcIde.hs @@ -0,0 +1,35 @@ +{-# LANGUAGE OverloadedStrings #-} +module Ide.Plugin.GhcIde + ( + descriptor + ) where + +import Development.IDE.Types.Logger +import Ide.Types +import Development.IDE.LSP.HoverDefinition +import Development.IDE.Core.Shake + +-- --------------------------------------------------------------------- + +descriptor :: PluginId -> PluginDescriptor +descriptor plId = PluginDescriptor + { pluginId = plId + , pluginRules = mempty + , pluginCommands = [] + , pluginCodeActionProvider = Nothing + , pluginCodeLensProvider = Nothing + , pluginDiagnosticProvider = Nothing + , pluginHoverProvider = Just hover' + , pluginSymbolsProvider = Nothing + , pluginFormattingProvider = Nothing + , pluginCompletionProvider = Nothing + } + +-- --------------------------------------------------------------------- + +hover' :: HoverProvider +hover' ideState params = do + logInfo (ideLogger ideState) "GhcIde.hover entered (ideLogger)" -- AZ + hover ideState params + +-- ---------------------------------------------------------------------