{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
module Development.IDE.Plugin.HLS.GhcIde
(
descriptors
) where
import Development.IDE
import Development.IDE.LSP.HoverDefinition
import Development.IDE.LSP.Outline
import Ide.PluginUtils
import Ide.Types
import Language.Haskell.LSP.Types
import Text.Regex.TDFA.Text()
import qualified Development.IDE.Plugin.CodeAction as CodeAction
import qualified Development.IDE.Plugin.Completions as Completions
import qualified Development.IDE.Plugin.TypeLenses as TypeLenses
descriptors :: [PluginDescriptor IdeState]
descriptors :: [PluginDescriptor IdeState]
descriptors =
[ PluginId -> PluginDescriptor IdeState
descriptor PluginId
"ghcide-hover-and-symbols",
PluginId -> PluginDescriptor IdeState
CodeAction.descriptor PluginId
"ghcide-code-actions",
PluginId -> PluginDescriptor IdeState
Completions.descriptor PluginId
"ghcide-completions",
PluginId -> PluginDescriptor IdeState
TypeLenses.descriptor PluginId
"ghcide-type-lenses"
]
descriptor :: PluginId -> PluginDescriptor IdeState
descriptor :: PluginId -> PluginDescriptor IdeState
descriptor PluginId
plId = (PluginId -> PluginDescriptor IdeState
forall ideState. PluginId -> PluginDescriptor ideState
defaultPluginDescriptor PluginId
plId)
{ pluginHoverProvider :: Maybe (HoverProvider IdeState)
pluginHoverProvider = HoverProvider IdeState -> Maybe (HoverProvider IdeState)
forall a. a -> Maybe a
Just HoverProvider IdeState
hover'
, pluginSymbolsProvider :: Maybe (SymbolsProvider IdeState)
pluginSymbolsProvider = SymbolsProvider IdeState -> Maybe (SymbolsProvider IdeState)
forall a. a -> Maybe a
Just SymbolsProvider IdeState
symbolsProvider
}
hover' :: HoverProvider IdeState
hover' :: HoverProvider IdeState
hover' IdeState
ideState TextDocumentPositionParams
params = do
Logger -> Text -> IO ()
logDebug (IdeState -> Logger
ideLogger IdeState
ideState) Text
"GhcIde.hover entered (ideLogger)"
HoverProvider IdeState
hover IdeState
ideState TextDocumentPositionParams
params
symbolsProvider :: SymbolsProvider IdeState
symbolsProvider :: SymbolsProvider IdeState
symbolsProvider LspFuncs Config
ls IdeState
ide DocumentSymbolParams
params = do
Either ResponseError DSResult
ds <- LspFuncs Config
-> IdeState
-> DocumentSymbolParams
-> IO (Either ResponseError DSResult)
forall c.
LspFuncs c
-> IdeState
-> DocumentSymbolParams
-> IO (Either ResponseError DSResult)
moduleOutline LspFuncs Config
ls IdeState
ide DocumentSymbolParams
params
case Either ResponseError DSResult
ds of
Right (DSDocumentSymbols (List [DocumentSymbol]
ls)) -> Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol])
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol]))
-> Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol])
forall a b. (a -> b) -> a -> b
$ [DocumentSymbol] -> Either ResponseError [DocumentSymbol]
forall a b. b -> Either a b
Right [DocumentSymbol]
ls
Right (DSSymbolInformation (List [SymbolInformation]
_si)) ->
Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol])
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol]))
-> Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol])
forall a b. (a -> b) -> a -> b
$ ResponseError -> Either ResponseError [DocumentSymbol]
forall a b. a -> Either a b
Left (ResponseError -> Either ResponseError [DocumentSymbol])
-> ResponseError -> Either ResponseError [DocumentSymbol]
forall a b. (a -> b) -> a -> b
$ Text -> ResponseError
responseError Text
"GhcIde.symbolsProvider: DSSymbolInformation deprecated"
Left ResponseError
err -> Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol])
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol]))
-> Either ResponseError [DocumentSymbol]
-> IO (Either ResponseError [DocumentSymbol])
forall a b. (a -> b) -> a -> b
$ ResponseError -> Either ResponseError [DocumentSymbol]
forall a b. a -> Either a b
Left ResponseError
err