hls-plugin-api 2.7.0.0 → 2.8.0.0
raw patch · 5 files changed
+55/−35 lines, 5 filesdep ~hls-graphPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hls-graph
API changes (from Hackage documentation)
- Ide.Logger: Logger :: (Priority -> Text -> IO ()) -> Logger
- Ide.Logger: [logPriority] :: Logger -> Priority -> Text -> IO ()
- Ide.Logger: instance GHC.Base.Monoid Ide.Logger.Logger
- Ide.Logger: instance GHC.Base.Semigroup Ide.Logger.Logger
- Ide.Logger: logDebug :: Logger -> Text -> IO ()
- Ide.Logger: logError :: Logger -> Text -> IO ()
- Ide.Logger: logInfo :: Logger -> Text -> IO ()
- Ide.Logger: logWarning :: Logger -> Text -> IO ()
- Ide.Logger: newtype Logger
- Ide.Logger: noLogging :: Logger
+ Ide.Logger: defaultLoggingColumns :: [LoggingColumn]
+ Ide.Plugin.Config: [$sel:sessionLoading:Config] :: Config -> !SessionLoadingPreferenceConfig
+ Ide.Types: PreferMultiComponentLoading :: SessionLoadingPreferenceConfig
+ Ide.Types: PreferSingleComponentLoading :: SessionLoadingPreferenceConfig
+ Ide.Types: [$sel:sessionLoading:Config] :: Config -> !SessionLoadingPreferenceConfig
+ Ide.Types: data SessionLoadingPreferenceConfig
+ Ide.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ide.Types.SessionLoadingPreferenceConfig
+ Ide.Types: instance Data.Aeson.Types.ToJSON.ToJSON Ide.Types.SessionLoadingPreferenceConfig
+ Ide.Types: instance GHC.Classes.Eq Ide.Types.SessionLoadingPreferenceConfig
+ Ide.Types: instance GHC.Classes.Ord Ide.Types.SessionLoadingPreferenceConfig
+ Ide.Types: instance GHC.Generics.Generic Ide.Types.SessionLoadingPreferenceConfig
+ Ide.Types: instance GHC.Show.Show Ide.Types.SessionLoadingPreferenceConfig
+ Ide.Types: instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentPrepareRename
+ Ide.Types: instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentPrepareRename
+ Ide.Types: instance Prettyprinter.Internal.Pretty Ide.Types.SessionLoadingPreferenceConfig
- Ide.Plugin.Config: Config :: CheckParents -> !Bool -> !Text -> !Text -> !Int -> !Map PluginId PluginConfig -> Config
+ Ide.Plugin.Config: Config :: CheckParents -> !Bool -> !Text -> !Text -> !Int -> !SessionLoadingPreferenceConfig -> !Map PluginId PluginConfig -> Config
- Ide.Types: Config :: CheckParents -> !Bool -> !Text -> !Text -> !Int -> !Map PluginId PluginConfig -> Config
+ Ide.Types: Config :: CheckParents -> !Bool -> !Text -> !Text -> !Int -> !SessionLoadingPreferenceConfig -> !Map PluginId PluginConfig -> Config
Files
- hls-plugin-api.cabal +2/−2
- src/Ide/Logger.hs +1/−30
- src/Ide/Plugin/Config.hs +1/−0
- src/Ide/Plugin/Resolve.hs +1/−0
- src/Ide/Types.hs +50/−3
hls-plugin-api.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-plugin-api-version: 2.7.0.0+version: 2.8.0.0 synopsis: Haskell Language Server API for plugin communication description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -66,7 +66,7 @@ , filepath , ghc , hashable- , hls-graph == 2.7.0.0+ , hls-graph == 2.8.0.0 , lens , lens-aeson , lsp ^>=2.4
src/Ide/Logger.hs view
@@ -10,10 +10,7 @@ -- framework they want to. module Ide.Logger ( Priority(..)- , Logger(..) , Recorder(..)- , logError, logWarning, logInfo, logDebug- , noLogging , WithPriority(..) , logWith , cmap@@ -30,6 +27,7 @@ , module PrettyPrinterModule , renderStrict , toCologActionWithPrio+ , defaultLoggingColumns ) where import Colog.Core (LogAction (..), Severity,@@ -48,7 +46,6 @@ import Data.Functor.Contravariant (Contravariant (contramap)) import Data.Maybe (fromMaybe) import Data.Text (Text)-import qualified Data.Text as T import qualified Data.Text as Text import qualified Data.Text.IO as Text import Data.Time (defaultTimeLocale, formatTime,@@ -80,32 +77,6 @@ -- should be investigated. | Error -- ^ Such log messages must never occur in expected usage. deriving (Eq, Show, Read, Ord, Enum, Bounded)---- | Note that this is logging actions _of the program_, not of the user.--- You shouldn't call warning/error if the user has caused an error, only--- if our code has gone wrong and is itself erroneous (e.g. we threw an exception).-newtype Logger = Logger {logPriority :: Priority -> T.Text -> IO ()}--instance Semigroup Logger where- l1 <> l2 = Logger $ \p t -> logPriority l1 p t >> logPriority l2 p t--instance Monoid Logger where- mempty = Logger $ \_ _ -> pure ()--logError :: Logger -> T.Text -> IO ()-logError x = logPriority x Error--logWarning :: Logger -> T.Text -> IO ()-logWarning x = logPriority x Warning--logInfo :: Logger -> T.Text -> IO ()-logInfo x = logPriority x Info--logDebug :: Logger -> T.Text -> IO ()-logDebug x = logPriority x Debug--noLogging :: Logger-noLogging = Logger $ \_ _ -> return () data WithPriority a = WithPriority { priority :: Priority, callStack_ :: CallStack, payload :: a } deriving Functor
src/Ide/Plugin/Config.hs view
@@ -42,6 +42,7 @@ <*> o .:? "formattingProvider" .!= formattingProvider defValue <*> o .:? "cabalFormattingProvider" .!= cabalFormattingProvider defValue <*> o .:? "maxCompletions" .!= maxCompletions defValue+ <*> o .:? "sessionLoading" .!= sessionLoading defValue <*> A.explicitParseFieldMaybe (parsePlugins idePlugins) o "plugin" .!= plugins defValue -- | Parse the 'PluginConfig'.
src/Ide/Plugin/Resolve.hs view
@@ -203,6 +203,7 @@ parseError value errMsg = PluginInternalError ("Ide.Plugin.Resolve: Error parsing value:"<> (T.pack $ show value) <> " Error: "<> errMsg) {- Note [Code action resolve fallback to commands]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To make supporting code action resolve easy for plugins, we want to let them provide one implementation that can be used both when clients support resolve, and when they don't.
src/Ide/Types.hs view
@@ -22,7 +22,7 @@ , IdeNotification(..) , IdePlugins(IdePlugins, ipMap) , DynFlagsModifications(..)-, Config(..), PluginConfig(..), CheckParents(..)+, Config(..), PluginConfig(..), CheckParents(..), SessionLoadingPreferenceConfig(..) , ConfigDescriptor(..), defaultConfigDescriptor, configForPlugin , CustomConfig(..), mkCustomConfig , FallbackCodeActionParams(..)@@ -65,6 +65,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift)) import Control.Monad.Trans.Except (ExceptT, runExceptT) import Data.Aeson hiding (Null, defaultOptions)+import qualified Data.Aeson.Types as A import Data.Default import Data.Dependent.Map (DMap) import qualified Data.Dependent.Map as DMap@@ -170,6 +171,7 @@ , formattingProvider :: !T.Text , cabalFormattingProvider :: !T.Text , maxCompletions :: !Int+ , sessionLoading :: !SessionLoadingPreferenceConfig , plugins :: !(Map.Map PluginId PluginConfig) } deriving (Show,Eq) @@ -178,7 +180,9 @@ object [ "checkParents" .= checkParents , "checkProject" .= checkProject , "formattingProvider" .= formattingProvider+ , "cabalFormattingProvider" .= cabalFormattingProvider , "maxCompletions" .= maxCompletions+ , "sessionLoading" .= sessionLoading , "plugin" .= Map.mapKeysMonotonic (\(PluginId p) -> p) plugins ] @@ -189,9 +193,11 @@ , formattingProvider = "ormolu" -- , formattingProvider = "floskell" -- , formattingProvider = "stylish-haskell"- , cabalFormattingProvider = "cabal-fmt"+ , cabalFormattingProvider = "cabal-gild"+ -- , cabalFormattingProvider = "cabal-fmt" -- this string value needs to kept in sync with the value provided in HlsPlugins , maxCompletions = 40+ , sessionLoading = PreferSingleComponentLoading , plugins = mempty } @@ -204,6 +210,39 @@ deriving stock (Eq, Ord, Show, Generic) deriving anyclass (FromJSON, ToJSON) ++data SessionLoadingPreferenceConfig+ = PreferSingleComponentLoading+ -- ^ Always load only a singleComponent when a new component+ -- is discovered.+ | PreferMultiComponentLoading+ -- ^ Always prefer loading multiple components in the cradle+ -- at once. This might not be always possible, if the tool doesn't+ -- support multiple components loading.+ --+ -- The cradle can decide how to handle these situations, and whether+ -- to honour the preference at all.+ deriving stock (Eq, Ord, Show, Generic)++instance Pretty SessionLoadingPreferenceConfig where+ pretty PreferSingleComponentLoading = "Prefer Single Component Loading"+ pretty PreferMultiComponentLoading = "Prefer Multiple Components Loading"++instance ToJSON SessionLoadingPreferenceConfig where+ toJSON PreferSingleComponentLoading =+ String "singleComponent"+ toJSON PreferMultiComponentLoading =+ String "multipleComponents"++instance FromJSON SessionLoadingPreferenceConfig where+ parseJSON (String val) = case val of+ "singleComponent" -> pure PreferSingleComponentLoading+ "multipleComponents" -> pure PreferMultiComponentLoading+ _ -> A.prependFailure "parsing SessionLoadingPreferenceConfig failed, "+ (A.parseFail $ "Expected one of \"singleComponent\" or \"multipleComponents\" but got " <> T.unpack val )+ parseJSON o = A.prependFailure "parsing SessionLoadingPreferenceConfig failed, "+ (A.typeMismatch "String" o)+ -- | A PluginConfig is a generic configuration for a given HLS plugin. It -- provides a "big switch" to turn it on or off as a whole, as well as small -- switches per feature, and a slot for custom config.@@ -475,6 +514,9 @@ instance PluginMethod Request Method_TextDocumentRename where handlesRequest = pluginEnabledWithFeature plcRenameOn +instance PluginMethod Request Method_TextDocumentPrepareRename where+ handlesRequest = pluginEnabledWithFeature plcRenameOn+ instance PluginMethod Request Method_TextDocumentHover where handlesRequest = pluginEnabledWithFeature plcHoverOn @@ -599,7 +641,7 @@ --- instance PluginRequestMethod Method_TextDocumentCodeAction where combineResponses _method _config (ClientCapabilities _ textDocCaps _ _ _ _) (CodeActionParams _ _ _ _ context) resps =- InL $ fmap compat $ filter wasRequested $ concat $ mapMaybe nullToMaybe $ toList resps+ InL $ fmap compat $ concatMap (filter wasRequested) $ mapMaybe nullToMaybe $ toList resps where compat :: (Command |? CodeAction) -> (Command |? CodeAction) compat x@(InL _) = x@@ -657,6 +699,10 @@ instance PluginRequestMethod Method_TextDocumentRename where +instance PluginRequestMethod Method_TextDocumentPrepareRename where+ -- TODO more intelligent combining?+ combineResponses _ _ _ _ (x :| _) = x+ instance PluginRequestMethod Method_TextDocumentHover where combineResponses _ _ _ _ (mapMaybe nullToMaybe . toList -> hs :: [Hover]) = if null hs@@ -1182,6 +1228,7 @@ #endif {- Note [Resolve in PluginHandlers]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Resolve methods have a few guarantees that need to be made by HLS, specifically they need to only be called once, as neither their errors nor their responses can be easily combined. Whereas commands, which similarly have