Skip to content

Create plugin for wrapping the handlers from ghcide #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
11 changes: 9 additions & 2 deletions exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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 "."
Expand Down
2 changes: 1 addition & 1 deletion ghcide
1 change: 1 addition & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions src/Ide/Plugin/GhcIde.hs
Original file line number Diff line number Diff line change
@@ -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

-- ---------------------------------------------------------------------