packages feed

hls-plugin-api 2.1.0.0 → 2.2.0.0

raw patch · 5 files changed

+45/−39 lines, 5 filesdep ~hls-graphdep ~lspPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hls-graph, lsp

API changes (from Hackage documentation)

+ Ide.Types: instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceExecuteCommand

Files

hls-plugin-api.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name:          hls-plugin-api-version:       2.1.0.0+version:       2.2.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>@@ -59,10 +59,10 @@     , filepath     , ghc     , hashable-    , hls-graph             == 2.1.0.0+    , hls-graph             == 2.2.0.0     , lens     , lens-aeson-    , lsp                   ^>=2.1.0.0+    , lsp                   ^>=2.2     , mtl     , opentelemetry         >=0.4     , optparse-applicative
src/Ide/Plugin/Config.hs view
@@ -11,17 +11,16 @@     , CheckParents(..)     ) where -import           Control.Applicative-import           Control.Lens        (preview)-import           Data.Aeson          hiding (Error)-import qualified Data.Aeson          as A-import           Data.Aeson.Lens     (_String)-import qualified Data.Aeson.Types    as A+import           Control.Lens     (preview)+import           Data.Aeson       hiding (Error)+import qualified Data.Aeson       as A+import           Data.Aeson.Lens  (_String)+import qualified Data.Aeson.Types as A import           Data.Default-import qualified Data.Map.Strict     as Map-import           Data.Maybe          (fromMaybe)-import qualified Data.Text           as T-import           GHC.Exts            (toList)+import qualified Data.Map.Strict  as Map+import           Data.Maybe       (fromMaybe)+import qualified Data.Text        as T+import           GHC.Exts         (toList) import           Ide.Types  -- ---------------------------------------------------------------------@@ -37,19 +36,14 @@ -- ---------------------------------------------------------------------  parseConfig :: IdePlugins s -> Config -> Value -> A.Parser Config-parseConfig idePlugins defValue = A.withObject "Config" $ \v -> do-    -- Officially, we use "haskell" as the section name but for-    -- backwards compatibility we also accept "languageServerHaskell"-    c <- v .: "haskell" <|> v .:? "languageServerHaskell"-    case c of-      Nothing -> return defValue-      Just s -> flip (A.withObject "Config.settings") s $ \o -> Config-        <$> (o .:? "checkParents" <|> v .:? "checkParents") .!= checkParents defValue-        <*> (o .:? "checkProject" <|> v .:? "checkProject") .!= checkProject defValue-        <*> o .:? "formattingProvider"                      .!= formattingProvider defValue-        <*> o .:? "cabalFormattingProvider"                 .!= cabalFormattingProvider defValue-        <*> o .:? "maxCompletions"                          .!= maxCompletions defValue-        <*> A.explicitParseFieldMaybe (parsePlugins idePlugins) o "plugin" .!= plugins defValue+parseConfig idePlugins defValue = A.withObject "settings" $ \o ->+  Config+    <$> o .:? "checkParents"                            .!= checkParents defValue+    <*> o .:? "checkProject"                            .!= checkProject defValue+    <*> o .:? "formattingProvider"                      .!= formattingProvider defValue+    <*> o .:? "cabalFormattingProvider"                 .!= cabalFormattingProvider defValue+    <*> o .:? "maxCompletions"                          .!= maxCompletions defValue+    <*> A.explicitParseFieldMaybe (parsePlugins idePlugins) o "plugin" .!= plugins defValue  -- | Parse the 'PluginConfig'. --   Since we need to fall back to default values if we do not find one in the input,
src/Ide/Plugin/ConfigUtils.hs view
@@ -5,7 +5,7 @@  module Ide.Plugin.ConfigUtils where -import           Control.Lens                  (at, ix, (&), (?~))+import           Control.Lens                  (at, (&), (?~)) import qualified Data.Aeson                    as A import           Data.Aeson.Lens               (_Object) import qualified Data.Aeson.Types              as A@@ -29,10 +29,9 @@ -- | Generates a default 'Config', but remains only effective items pluginsToDefaultConfig :: IdePlugins a -> A.Value pluginsToDefaultConfig IdePlugins {..} =-  -- Use 'ix' to look at all the "haskell" keys in the outer value (since we're not-  -- setting it if missing), then we use '_Object' and 'at' to get at the "plugin" key+  -- Use '_Object' and 'at' to get at the "plugin" key   -- and actually set it.-  A.toJSON defaultConfig & ix "haskell" . _Object . at "plugin" ?~ elems+  A.toJSON defaultConfig & _Object . at "plugin" ?~ elems   where     defaultConfig@Config {} = def     elems = A.object $ mconcat $ singlePlugin <$> ipMap
src/Ide/Plugin/Resolve.hs view
@@ -6,6 +6,18 @@ {-# LANGUAGE OverloadedStrings        #-} {-# LANGUAGE RankNTypes               #-} {-# LANGUAGE ScopedTypeVariables      #-}+{-| This module currently includes helper functions to provide fallback support+to code actions that use resolve in HLS. The difference between the two+functions for code actions that don't support resolve is that+mkCodeActionHandlerWithResolve will immediately resolve your code action before+sending it on to the client, while  mkCodeActionWithResolveAndCommand will turn+your resolve into a command.++General support for resolve in HLS can be used with mkResolveHandler from+Ide.Types. Resolve theoretically should allow us to delay computation of parts+of the request till the client needs it, allowing us to answer requests faster+and with less resource usage.+-} module Ide.Plugin.Resolve (mkCodeActionHandlerWithResolve, mkCodeActionWithResolveAndCommand) where@@ -41,7 +53,7 @@         DoesNotSupportResolve fallback->             "Client does not support resolve," <+> pretty fallback         ApplyWorkspaceEditFailed err ->-            "ApplyWorkspaceEditFailed:" <+> viaShow err+            "ApplyWorkspaceEditFailed:" <+> pretty err  -- |When provided with both a codeAction provider and an affiliated codeAction -- resolve provider, this function creates a handler that automatically uses
src/Ide/Types.hs view
@@ -179,14 +179,12 @@  instance ToJSON Config where   toJSON Config{..} =-      object [ "haskell" .= r ]-    where-      r = object [ "checkParents"                .= checkParents-                 , "checkProject"                .= checkProject-                 , "formattingProvider"          .= formattingProvider-                 , "maxCompletions"              .= maxCompletions-                 , "plugin"                      .= Map.mapKeysMonotonic (\(PluginId p) -> p) plugins-                 ]+    object [ "checkParents"                .= checkParents+           , "checkProject"                .= checkProject+           , "formattingProvider"          .= formattingProvider+           , "maxCompletions"              .= maxCompletions+           , "plugin"                      .= Map.mapKeysMonotonic (\(PluginId p) -> p) plugins+           ]  instance Default Config where   def = Config@@ -530,6 +528,9 @@ instance PluginMethod Request Method_CallHierarchyOutgoingCalls where   -- This method has no URI parameter, thus no call to 'pluginResponsible'   pluginEnabled _ _ pluginDesc conf = pluginEnabledConfig plcCallHierarchyOn (configForPlugin conf pluginDesc)++instance PluginMethod Request Method_WorkspaceExecuteCommand where+  pluginEnabled _ _ _ _= True  instance PluginMethod Request (Method_CustomMethod m) where   pluginEnabled _ _ _ _ = True