Skip to content

Commit df199db

Browse files
authored
Merge pull request #58 from alanz/ghcide-hover-too
Create plugin for wrapping the handlers from ghcide
2 parents 17b150b + 8299f25 commit df199db

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

.circleci/config.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,21 @@ jobs:
148148
- cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
149149
- run:
150150
name: Update
151-
command: cabal update
151+
command: cabal new-update
152152
- run:
153153
name: Configure
154-
command: cabal configure --enable-tests
154+
command: cabal new-configure --enable-tests
155+
- run:
156+
name: Build dependencies
157+
command: cabal new-build -j1 --dependencies-only # need j1, else ghc-lib-parser triggers OOM
158+
no_output_timeout: 30m
159+
- save_cache:
160+
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
161+
paths:
162+
- ~/.cabal
155163
- run:
156164
name: Build
157-
command: cabal build -j1 # need j1, else ghc-lib-parser triggers OOM
165+
command: cabal new-build -j1 # need j1, else ghc-lib-parser triggers OOM
158166
no_output_timeout: 30m
159167
- save_cache:
160168
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}

exe/Main.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,20 @@ import System.Log.Logger as L
5858
import System.Time.Extra
5959

6060
-- ---------------------------------------------------------------------
61-
61+
-- ghcide partialhandlers
6262
import Development.IDE.Plugin.CodeAction as CodeAction
6363
import Development.IDE.Plugin.Completions as Completions
64+
import Development.IDE.LSP.HoverDefinition as HoverDefinition
65+
66+
-- haskell-language-server plugins
6467
import Ide.Plugin.Example as Example
6568
import Ide.Plugin.Example2 as Example2
69+
import Ide.Plugin.GhcIde as GhcIde
6670
import Ide.Plugin.Floskell as Floskell
6771
import Ide.Plugin.Ormolu as Ormolu
6872
import Ide.Plugin.Pragmas as Pragmas
6973

74+
7075
-- ---------------------------------------------------------------------
7176

7277
-- | The plugins configured for use in this instance of the language
@@ -90,7 +95,8 @@ idePlugins pid includeExamples
9095
-- , hsimportDescriptor "hsimport"
9196
-- , liquidDescriptor "liquid"
9297
-- , packageDescriptor "package"
93-
Pragmas.descriptor "pragmas"
98+
GhcIde.descriptor "ghc"
99+
, Pragmas.descriptor "pragmas"
94100
, Floskell.descriptor "floskell"
95101
-- , genericDescriptor "generic"
96102
-- , ghcmodDescriptor "ghcmod"
@@ -145,6 +151,7 @@ main = do
145151
-- (ps, commandIds) = idePlugins pid argsExamplePlugin
146152
(ps, commandIds) = idePlugins pid True
147153
plugins = Completions.plugin <> CodeAction.plugin <>
154+
Plugin mempty HoverDefinition.setHandlersDefinition <>
148155
ps
149156
options = def { LSP.executeCommandCommands = Just commandIds
150157
, LSP.completionTriggerCharacters = Just "."

ghcide

haskell-language-server.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ library
3434
Ide.Plugin.Config
3535
Ide.Plugin.Example
3636
Ide.Plugin.Example2
37+
Ide.Plugin.GhcIde
3738
Ide.Plugin.Ormolu
3839
Ide.Plugin.Pragmas
3940
Ide.Plugin.Floskell

src/Ide/Plugin/GhcIde.hs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
module Ide.Plugin.GhcIde
3+
(
4+
descriptor
5+
) where
6+
7+
import Development.IDE.Types.Logger
8+
import Ide.Types
9+
import Development.IDE.LSP.HoverDefinition
10+
import Development.IDE.Core.Shake
11+
12+
-- ---------------------------------------------------------------------
13+
14+
descriptor :: PluginId -> PluginDescriptor
15+
descriptor plId = PluginDescriptor
16+
{ pluginId = plId
17+
, pluginRules = mempty
18+
, pluginCommands = []
19+
, pluginCodeActionProvider = Nothing
20+
, pluginCodeLensProvider = Nothing
21+
, pluginDiagnosticProvider = Nothing
22+
, pluginHoverProvider = Just hover'
23+
, pluginSymbolsProvider = Nothing
24+
, pluginFormattingProvider = Nothing
25+
, pluginCompletionProvider = Nothing
26+
}
27+
28+
-- ---------------------------------------------------------------------
29+
30+
hover' :: HoverProvider
31+
hover' ideState params = do
32+
logInfo (ideLogger ideState) "GhcIde.hover entered (ideLogger)" -- AZ
33+
hover ideState params
34+
35+
-- ---------------------------------------------------------------------

0 commit comments

Comments
 (0)