-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell Language Server API for plugin communication -- -- Please see the README on GitHub at -- https://github.com/haskell/haskell-language-server#readme @package hls-plugin-api @version 2.7.0.0 -- | This is a compatibility module that abstracts over the concrete choice -- of logging framework so users can plug in whatever framework they want -- to. module Ide.Logger data Priority -- | Verbose debug logging. Debug :: Priority -- | Useful information in case an error has to be understood. Info :: Priority -- | These error messages should not occur in a expected usage, and should -- be investigated. Warning :: Priority -- | Such log messages must never occur in expected usage. Error :: Priority -- | 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 :: (Priority -> Text -> IO ()) -> Logger [logPriority] :: Logger -> Priority -> Text -> IO () -- | 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 Recorder msg Recorder :: (forall m. MonadIO m => msg -> m ()) -> Recorder msg [logger_] :: Recorder msg -> forall m. MonadIO m => msg -> m () logError :: Logger -> Text -> IO () logWarning :: Logger -> Text -> IO () logInfo :: Logger -> Text -> IO () logDebug :: Logger -> Text -> IO () noLogging :: Logger data WithPriority a WithPriority :: Priority -> CallStack -> a -> WithPriority a [priority] :: WithPriority a -> Priority [callStack_] :: WithPriority a -> CallStack [payload] :: WithPriority a -> a logWith :: (HasCallStack, MonadIO m) => Recorder (WithPriority msg) -> Priority -> msg -> m () cmap :: (a -> b) -> Recorder b -> Recorder a cmapIO :: (a -> IO b) -> Recorder b -> Recorder a cfilter :: (a -> Bool) -> Recorder a -> Recorder a withFileRecorder :: MonadUnliftIO m => FilePath -> Maybe [LoggingColumn] -> (Either IOException (Recorder (WithPriority (Doc d))) -> m a) -> m a makeDefaultStderrRecorder :: MonadIO m => Maybe [LoggingColumn] -> m (Recorder (WithPriority (Doc a))) makeDefaultHandleRecorder :: MonadIO m => Maybe [LoggingColumn] -> Lock -> Handle -> m (Recorder (WithPriority (Doc a))) data LoggingColumn TimeColumn :: LoggingColumn ThreadIdColumn :: LoggingColumn PriorityColumn :: LoggingColumn DataColumn :: LoggingColumn SourceLocColumn :: LoggingColumn cmapWithPrio :: (a -> b) -> Recorder (WithPriority b) -> Recorder (WithPriority a) -- | Given a Recorder that requires an argument, produces a -- Recorder that queues up messages until the argument is provided -- using the callback, at which point it sends the backlog and begins -- functioning normally. withBacklog :: (v -> Recorder a) -> IO (Recorder a, v -> IO ()) -- | Creates a recorder that sends logs to the LSP client via -- window/showMessage notifications. lspClientMessageRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text) -- | Creates a recorder that sends logs to the LSP client via -- window/logMessage notifications. lspClientLogRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text) -- | (renderStrict sdoc) takes the output sdoc -- from a rendering function and transforms it to strict text. renderStrict :: SimpleDocStream ann -> Text toCologActionWithPrio :: (MonadIO m, HasCallStack) => Recorder (WithPriority msg) -> LogAction m (WithSeverity msg) instance GHC.Enum.Bounded Ide.Logger.Priority instance GHC.Enum.Enum Ide.Logger.Priority instance GHC.Classes.Ord Ide.Logger.Priority instance GHC.Read.Read Ide.Logger.Priority instance GHC.Show.Show Ide.Logger.Priority instance GHC.Classes.Eq Ide.Logger.Priority instance GHC.Base.Functor Ide.Logger.WithPriority instance GHC.Base.Semigroup (Ide.Logger.Recorder msg) instance GHC.Base.Monoid (Ide.Logger.Recorder msg) instance Data.Functor.Contravariant.Contravariant Ide.Logger.Recorder instance GHC.Base.Semigroup Ide.Logger.Logger instance GHC.Base.Monoid Ide.Logger.Logger module Ide.Plugin.HandleRequestTypes -- | Reasons why a plugin could reject a specific request. data RejectionReason -- | The resolve request is not meant for this plugin or handler. The text -- field should contain the identifier for the plugin who owns this -- resolve request. NotResolveOwner :: Text -> RejectionReason -- | The plugin is disabled globally in the users config. DisabledGlobally :: RejectionReason -- | The feature in the plugin that responds to this request is disabled in -- the users config FeatureDisabled :: RejectionReason -- | This plugin is not the formatting provider selected in the users -- config. The text should be the formatting provider in your config. NotFormattingProvider :: Text -> RejectionReason -- | This plugin does not support the file type. The text field here should -- contain the filetype of the rejected request. DoesNotSupportFileType :: Text -> RejectionReason -- | Whether a plugin will handle a request or not. data HandleRequestResult HandlesRequest :: HandleRequestResult DoesNotHandleRequest :: RejectionReason -> HandleRequestResult instance GHC.Classes.Eq Ide.Plugin.HandleRequestTypes.RejectionReason instance GHC.Classes.Eq Ide.Plugin.HandleRequestTypes.HandleRequestResult instance Prettyprinter.Internal.Pretty Ide.Plugin.HandleRequestTypes.HandleRequestResult instance GHC.Base.Semigroup Ide.Plugin.HandleRequestTypes.HandleRequestResult instance Prettyprinter.Internal.Pretty Ide.Plugin.HandleRequestTypes.RejectionReason module Ide.Plugin.Error -- | Each PluginError corresponds to either a specific ResponseError we -- want to return or a specific way we want to log the error. If the -- currently present ones are insufficient for the needs of your plugin, -- please feel free to add a new one. -- -- Currently the PluginErrors we provide can be broken up into several -- groups. First is PluginInternalError, which is the most serious of the -- errors, and also the "default" error that is used for things such as -- uncaught exceptions. Then we have PluginInvalidParams, which along -- with PluginInternalError map to a corresponding ResponseError. -- -- Next we have PluginRuleFailed and PluginInvalidUserState, with the -- only difference being PluginRuleFailed is specific to Shake rules and -- PluginInvalidUserState can be used for everything else. Both of these -- are "non-errors", and happen whenever the user's code is in a state -- where the plugin is unable to provide a answer to the users request. -- PluginStaleResolve is similar to the above two Error types, but is -- specific to resolve plugins, and is used only when the data provided -- by the resolve request is stale, preventing the proper resolution of -- it. -- -- Finally we have the outlier, PluginRequestRefused, where we allow a -- handler to preform "pluginEnabled" checks inside the handler, and -- reject the request after viewing it. The behavior of only one handler -- passing pluginEnabled and then returning PluginRequestRefused -- should be the same as if no plugins passed the pluginEnabled -- stage. data PluginError -- | PluginInternalError should be used if an error has occurred. This -- should only rarely be returned. As it's logged with Error, it will be -- shown by the client to the user via showWindow. All uncaught -- exceptions will be caught and converted to this error. -- -- This error will be be converted into an InternalError response code. -- It will be logged with Error and takes the highest precedence (1) in -- being returned as a response to the client. PluginInternalError :: Text -> PluginError -- | PluginInvalidParams should be used if the parameters of the request -- are invalid. This error means that there is a bug in the client's code -- (otherwise they wouldn't be sending you requests with invalid -- parameters). -- -- This error will be will be converted into a InvalidParams response -- code. It will be logged with Warning and takes medium precedence (2) -- in being returned as a response to the client. PluginInvalidParams :: Text -> PluginError -- | PluginInvalidUserState should be thrown when a function that your -- plugin depends on fails. This should only be used when the function -- fails because the user's code is in an invalid state. -- -- This error takes the name of the function that failed. Prefer to catch -- this error as close to the source as possible. -- -- This error will be logged with Debug, and will be converted into a -- RequestFailed response. It takes a low precedence (3) in being -- returned as a response to the client. PluginInvalidUserState :: Text -> PluginError -- | PluginRequestRefused allows your handler to inspect a request before -- rejecting it. In effect it allows your plugin to act make a secondary -- handlesRequest decision after receiving the request. This -- should only be used if the decision to accept the request can not be -- made in handlesRequest. -- -- This error will be with Debug. If it's the only response to a request, -- HLS will respond as if no plugins passed the handlesRequest -- stage. PluginRequestRefused :: RejectionReason -> PluginError -- | PluginRuleFailed should be thrown when a Rule your response depends on -- fails. -- -- This error takes the name of the Rule that failed. -- -- This error will be logged with Debug, and will be converted into a -- RequestFailed response code. It takes a low precedence (3) in being -- returned as a response to the client. PluginRuleFailed :: Text -> PluginError -- | PluginStaleResolve should be thrown when your resolve request is -- provided with data it can no longer resolve. -- -- This error will be logged with Debug, and will be converted into a -- ContentModified response. It takes a low precedence (3) in being -- returned as a response to the client. PluginStaleResolve :: PluginError -- | Converts to ErrorCode used in LSP ResponseErrors toErrorCode :: PluginError -> LSPErrorCodes |? ErrorCodes -- | Converts to a logging priority. In addition to being used by the -- logger, combineResponses currently uses this to choose which -- response to return, so care should be taken in changing it. toPriority :: PluginError -> Priority handleMaybe :: Monad m => e -> Maybe b -> ExceptT e m b handleMaybeM :: Monad m => e -> m (Maybe b) -> ExceptT e m b getNormalizedFilePathE :: Monad m => Uri -> ExceptT PluginError m NormalizedFilePath instance Prettyprinter.Internal.Pretty Ide.Plugin.Error.PluginError module Ide.Plugin.Properties -- | Types properties may have data PropertyType TNumber :: PropertyType TInteger :: PropertyType TString :: PropertyType TBoolean :: PropertyType TObject :: Type -> PropertyType TArray :: Type -> PropertyType TEnum :: Type -> PropertyType type family ToHsType (t :: PropertyType) type family NotElem (s :: Symbol) (r :: [PropertyKey]) :: Constraint -- | Metadata of a property data MetaData (t :: PropertyType) [MetaData] :: IsTEnum t ~ 'False => ToHsType t -> Text -> MetaData t [EnumMetaData] :: IsTEnum t ~ 'True => ToHsType t -> Text -> [ToHsType t] -> [Text] -> MetaData t -- | Used at type level for name-type mapping in Properties data PropertyKey PropertyKey :: Symbol -> PropertyType -> PropertyKey -- | Singleton type of PropertyKey data SPropertyKey (k :: PropertyKey) [SNumber] :: SPropertyKey ('PropertyKey s 'TNumber) [SInteger] :: SPropertyKey ('PropertyKey s 'TInteger) [SString] :: SPropertyKey ('PropertyKey s 'TString) [SBoolean] :: SPropertyKey ('PropertyKey s 'TBoolean) [SObject] :: (ToJSON a, FromJSON a) => Proxy a -> SPropertyKey ('PropertyKey s ('TObject a)) [SArray] :: (ToJSON a, FromJSON a) => Proxy a -> SPropertyKey ('PropertyKey s ('TArray a)) [SEnum] :: (ToJSON a, FromJSON a, Eq a, Show a) => Proxy a -> SPropertyKey ('PropertyKey s ('TEnum a)) -- | A proxy type in order to allow overloaded labels as properties' names -- at the call site data KeyNameProxy (s :: Symbol) KeyNameProxy :: KeyNameProxy (s :: Symbol) -- | Properties is a partial implementation of json schema, without -- supporting union types and validation. In hls, it defines a set of -- properties used in dedicated configuration of a plugin. A property is -- an immediate child of the json object in each plugin's "config" -- section. It was designed to be compatible with vscode's settings UI. -- Use emptyProperties and useProperty to create and -- consume Properties. data Properties (r :: [PropertyKey]) -- | In row r, there is a PropertyKey k, which has -- name s and carries haskell type t type HasProperty s k t r = (k ~ 'PropertyKey s t, Elem s r, FindByKeyName s r ~ t, KnownSymbol s, FindPropertyMeta s r t) -- | Creates a Properties that defines no property -- -- Useful to start a definitions chain, for example: properties = -- emptyProperties & defineStringProperty #exampleString "Description -- of exampleString" Foo & defineNumberProperty #exampleNumber -- "Description of exampleNumber" 233 emptyProperties :: Properties '[] -- | Defines a number property defineNumberProperty :: (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Double -> Properties r -> Properties ('PropertyKey s 'TNumber : r) -- | Defines an integer property defineIntegerProperty :: (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Int -> Properties r -> Properties ('PropertyKey s 'TInteger : r) -- | Defines a string property defineStringProperty :: (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Text -> Properties r -> Properties ('PropertyKey s 'TString : r) -- | Defines a boolean property defineBooleanProperty :: (KnownSymbol s, NotElem s r) => KeyNameProxy s -> Text -> Bool -> Properties r -> Properties ('PropertyKey s 'TBoolean : r) -- | Defines an object property defineObjectProperty :: (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) => KeyNameProxy s -> Text -> a -> Properties r -> Properties ('PropertyKey s ('TObject a) : r) -- | Defines an array property defineArrayProperty :: (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a) => KeyNameProxy s -> Text -> [a] -> Properties r -> Properties ('PropertyKey s ('TArray a) : r) -- | Defines an enum property defineEnumProperty :: (KnownSymbol s, NotElem s r, ToJSON a, FromJSON a, Eq a, Show a) => KeyNameProxy s -> Text -> [(a, Text)] -> a -> Properties r -> Properties ('PropertyKey s ('TEnum a) : r) -- | Converts a properties definition into kv pairs with default values -- from MetaData toDefaultJSON :: Properties r -> [Pair] -- | Converts a properties definition into kv pairs as vscode schema toVSCodeExtensionSchema :: Text -> Properties r -> [Pair] -- | Given the name of a defined property, generates a JSON parser of -- plcConfig usePropertyEither :: HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> Either String (ToHsType t) -- | Like usePropertyEither but returns defaultValue on parse -- error useProperty :: HasProperty s k t r => KeyNameProxy s -> Properties r -> Object -> ToHsType t -- | & is a reverse application operator. This provides -- notational convenience. Its precedence is one higher than that of the -- forward application operator $, which allows & to be -- nested in $. -- --
--   >>> 5 & (+1) & show
--   "6"
--   
(&) :: a -> (a -> b) -> b infixl 1 & instance Ide.Plugin.Properties.FindPropertyMetaIf (Ide.Plugin.Properties.IsPropertySymbol symbol k) symbol k ks t => Ide.Plugin.Properties.FindPropertyMeta symbol (k : ks) t instance (k GHC.Types.~ 'Ide.Plugin.Properties.PropertyKey s t) => Ide.Plugin.Properties.FindPropertyMetaIf 'GHC.Types.True s k ks t instance ('GHC.Types.False GHC.Types.~ Ide.Plugin.Properties.IsPropertySymbol s k, Ide.Plugin.Properties.FindPropertyMeta s ks t) => Ide.Plugin.Properties.FindPropertyMetaIf 'GHC.Types.False s k ks t instance (GHC.TypeLits.KnownSymbol s', s GHC.Types.~ s') => GHC.OverloadedLabels.IsLabel s (Ide.Plugin.Properties.KeyNameProxy s') -- | A map that allows fast "in-range" filtering. RangeMap is meant -- to be constructed once and cached as part of a Shake rule. If not, the -- map will be rebuilt upon each invocation, yielding slower results -- compared to the list-based approach! -- -- Note that RangeMap falls back to the list-based approach if -- `use-fingertree` flag of `hls-plugin-api` is set to false. module Ide.Plugin.RangeMap -- | A map from code ranges to values. newtype RangeMap a RangeMap :: IntervalMap Position a -> RangeMap a -- | Interval of Position corresponds to a Range [unRangeMap] :: RangeMap a -> IntervalMap Position a -- | Construct a RangeMap from a Range accessor and a list of -- values. fromList :: (a -> Range) -> [a] -> RangeMap a fromList' :: [(Range, a)] -> RangeMap a -- | Filter a RangeMap by a given Range. filterByRange :: Range -> RangeMap a -> [a] instance Data.Traversable.Traversable Ide.Plugin.RangeMap.RangeMap instance Data.Foldable.Foldable Ide.Plugin.RangeMap.RangeMap instance GHC.Base.Functor Ide.Plugin.RangeMap.RangeMap instance GHC.Base.Monoid (Ide.Plugin.RangeMap.RangeMap a) instance GHC.Base.Semigroup (Ide.Plugin.RangeMap.RangeMap a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Ide.Plugin.RangeMap.RangeMap a) module Ide.Types data PluginDescriptor (ideState :: Type) PluginDescriptor :: !PluginId -> !Text -> Natural -> !Rules () -> ![PluginCommand ideState] -> PluginHandlers ideState -> ConfigDescriptor -> PluginNotificationHandlers ideState -> DynFlagsModifications -> Maybe (ParserInfo (IdeCommand ideState)) -> [Text] -> PluginDescriptor (ideState :: Type) [$sel:pluginId:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> !PluginId -- | Unique identifier of the plugin. [$sel:pluginDescription:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> !Text -- | Plugin handlers are called in priority order, higher priority first [$sel:pluginPriority:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> Natural [$sel:pluginRules:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> !Rules () [$sel:pluginCommands:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> ![PluginCommand ideState] [$sel:pluginHandlers:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> PluginHandlers ideState [$sel:pluginConfigDescriptor:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> ConfigDescriptor [$sel:pluginNotificationHandlers:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> PluginNotificationHandlers ideState [$sel:pluginModifyDynflags:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> DynFlagsModifications [$sel:pluginCli:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> Maybe (ParserInfo (IdeCommand ideState)) -- | File extension of the files the plugin is responsible for. The plugin -- is only allowed to handle files with these extensions. When writing -- handlers, etc. for this plugin it can be assumed that all handled -- files are of this type. The file extension must have a leading -- .. [$sel:pluginFileType:PluginDescriptor] :: PluginDescriptor (ideState :: Type) -> [Text] -- | Set up a plugin descriptor, initialized with default values. This -- plugin descriptor is prepared for haskell files, such as -- -- -- -- and handlers will be enabled for files with the appropriate file -- extensions. defaultPluginDescriptor :: PluginId -> Text -> PluginDescriptor ideState -- | Set up a plugin descriptor, initialized with default values. This -- plugin descriptor is prepared for .cabal files and as such, -- will only respond / run when .cabal files are currently in -- scope. -- -- Handles files with the following extensions: * .cabal defaultCabalPluginDescriptor :: PluginId -> Text -> PluginDescriptor ideState defaultPluginPriority :: Natural describePlugin :: PluginDescriptor c -> Doc ann newtype IdeCommand state IdeCommand :: (state -> IO ()) -> IdeCommand state -- | Methods which have a PluginMethod instance data IdeMethod (m :: Method ClientToServer Request) IdeMethod :: SMethod m -> IdeMethod (m :: Method ClientToServer Request) -- | Methods which have a PluginMethod instance data IdeNotification (m :: Method ClientToServer Notification) IdeNotification :: SMethod m -> IdeNotification (m :: Method ClientToServer Notification) data IdePlugins ideState -- | Smart constructor that deduplicates plugins pattern IdePlugins :: [PluginDescriptor ideState] -> IdePlugins ideState -- | Hooks for modifying the DynFlags at different times of the -- compilation process. Plugins can install a -- DynFlagsModifications via -- $sel:pluginModifyDynflags:PluginDescriptor in their -- PluginDescriptor. data DynFlagsModifications DynFlagsModifications :: (DynFlags -> DynFlags) -> (DynFlags -> DynFlags) -> DynFlagsModifications -- | Invoked immediately at the package level. Changes to the -- DynFlags made in -- $sel:dynFlagsModifyGlobal:DynFlagsModifications are guaranteed -- to be seen everywhere in the compilation pipeline. [$sel:dynFlagsModifyGlobal:DynFlagsModifications] :: DynFlagsModifications -> DynFlags -> DynFlags -- | Invoked just before the parsing step, and reset immediately -- afterwards. $sel:dynFlagsModifyParser:DynFlagsModifications -- allows plugins to enable language extensions only during parsing. for -- example, to let them enable certain pieces of syntax. [$sel:dynFlagsModifyParser:DynFlagsModifications] :: DynFlagsModifications -> DynFlags -> DynFlags -- | We (initially anyway) mirror the hie configuration, so that existing -- clients can simply switch executable and not have any nasty surprises. -- There will initially be surprises relating to config options being -- ignored though. data Config Config :: CheckParents -> !Bool -> !Text -> !Text -> !Int -> !Map PluginId PluginConfig -> Config [$sel:checkParents:Config] :: Config -> CheckParents [$sel:checkProject:Config] :: Config -> !Bool [$sel:formattingProvider:Config] :: Config -> !Text [$sel:cabalFormattingProvider:Config] :: Config -> !Text [$sel:maxCompletions:Config] :: Config -> !Int [$sel:plugins:Config] :: Config -> !Map PluginId PluginConfig -- | 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. This -- provides a regular naming scheme for all plugin config. data PluginConfig PluginConfig :: !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Object -> PluginConfig [$sel:plcGlobalOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCallHierarchyOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCodeActionsOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCodeLensOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcDiagnosticsOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcHoverOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcSymbolsOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCompletionOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcRenameOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcSelectionRangeOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcFoldingRangeOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcSemanticTokensOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcConfig:PluginConfig] :: PluginConfig -> !Object data CheckParents NeverCheck :: CheckParents CheckOnSave :: CheckParents AlwaysCheck :: CheckParents -- | Describes the configuration of a plugin. A plugin may be configurable -- as can be seen below: -- --
--   {
--    "plugin-id": {
--      "globalOn": true,
--      "codeActionsOn": true,
--      "codeLensOn": true,
--      "config": {
--        "property1": "foo"
--       }
--     }
--   }
--   
-- -- globalOn, codeActionsOn, and codeLensOn -- etc. are called generic configs which can be inferred from handlers -- registered by the plugin. config is called custom config, -- which is defined using Properties. data ConfigDescriptor ConfigDescriptor :: PluginConfig -> Bool -> CustomConfig -> ConfigDescriptor -- | Initial values for the generic config [$sel:configInitialGenericConfig:ConfigDescriptor] :: ConfigDescriptor -> PluginConfig -- | Whether or not to generate diagnosticsOn config. Diagnostics -- emit in arbitrary shake rules, so we can't know statically if the -- plugin produces diagnostics [$sel:configHasDiagnostics:ConfigDescriptor] :: ConfigDescriptor -> Bool -- | Custom config. [$sel:configCustomConfig:ConfigDescriptor] :: ConfigDescriptor -> CustomConfig defaultConfigDescriptor :: ConfigDescriptor -- | Lookup the current config for a plugin configForPlugin :: Config -> PluginDescriptor c -> PluginConfig -- | An existential wrapper of Properties data CustomConfig CustomConfig :: Properties r -> CustomConfig mkCustomConfig :: Properties r -> CustomConfig data FallbackCodeActionParams FallbackCodeActionParams :: Maybe WorkspaceEdit -> Maybe Command -> FallbackCodeActionParams [$sel:fallbackWorkspaceEdit:FallbackCodeActionParams] :: FallbackCodeActionParams -> Maybe WorkspaceEdit [$sel:fallbackCommand:FallbackCodeActionParams] :: FallbackCodeActionParams -> Maybe Command -- | Format the given Text as a whole or only a Range of it. Range -- must be relative to the text to format. To format the whole document, -- read the Text from the file and use FormatText as the -- FormattingType. data FormattingType FormatText :: FormattingType FormatRange :: Range -> FormattingType type FormattingMethod m = (HasOptions (MessageParams m) FormattingOptions, HasTextDocument (MessageParams m) TextDocumentIdentifier, MessageResult m ~ ([TextEdit] |? Null)) type FormattingHandler a = a -> Maybe ProgressToken -> FormattingType -> Text -> NormalizedFilePath -> FormattingOptions -> ExceptT PluginError (LspM Config) ([TextEdit] |? Null) mkFormattingHandlers :: forall a. FormattingHandler a -> PluginHandlers a class HasTracing a traceWithSpan :: HasTracing a => SpanInFlight -> a -> IO () data PluginCommand ideState PluginCommand :: CommandId -> Text -> CommandFunction ideState a -> PluginCommand ideState [$sel:commandId:PluginCommand] :: PluginCommand ideState -> CommandId [$sel:commandDesc:PluginCommand] :: PluginCommand ideState -> Text [$sel:commandFunc:PluginCommand] :: PluginCommand ideState -> CommandFunction ideState a newtype CommandId CommandId :: Text -> CommandId type CommandFunction ideState a = ideState -> Maybe ProgressToken -> a -> ExceptT PluginError (LspM Config) (Value |? Null) mkLspCommand :: PluginId -> CommandId -> Text -> Maybe [Value] -> Command mkLspCmdId :: Text -> PluginId -> CommandId -> Text newtype PluginId PluginId :: Text -> PluginId -- | Combine handlers for the newtype PluginHandler a (m :: Method ClientToServer Request) PluginHandler :: (PluginId -> a -> MessageParams m -> LspM Config (NonEmpty (Either PluginError (MessageResult m)))) -> PluginHandler a (m :: Method ClientToServer Request) -- | Make a handler for plugins. For how resolve works with this see Note -- [Resolve in PluginHandlers] mkPluginHandler :: forall ideState m. PluginRequestMethod m => SClientMethod m -> PluginMethodHandler ideState m -> PluginHandlers ideState newtype PluginHandlers a PluginHandlers :: DMap IdeMethod (PluginHandler a) -> PluginHandlers a -- | Methods that can be handled by plugins. ExtraParams captures -- any extra data the IDE passes to the handlers for this method Only -- methods for which we know how to combine responses can be instances of -- PluginMethod class HasTracing (MessageParams m) => PluginMethod (k :: MessageKind) (m :: Method ClientToServer k) -- | Parse the configuration to check if this plugin is globally enabled, -- and if the feature which handles this method is enabled. Perform -- sanity checks on the message to see whether the plugin handles this -- message in particular. This class is only used to determine whether a -- plugin can handle a specific request. Commands and rules do not use -- this logic to determine whether or not they are run. -- -- A common reason why a plugin won't handle a request even though it is -- enabled: * The plugin cannot handle requests associated with the -- specific URI * Since the implementation of cabal plugins HLS -- knows plugins specific to Haskell and specific to Cabal file -- descriptions * The resolve request is not routed to that specific -- plugin. Each resolve request needs to be routed to only one plugin. -- -- Strictly speaking, we are conflating two concepts here: * Dynamically -- enabled (e.g. on a per-message basis) * Statically enabled (e.g. by -- configuration in the lsp-client) * Strictly speaking, this might also -- change dynamically -- -- But there is no use to split it up into two different methods for now. handlesRequest :: PluginMethod k m => SMethod m -> MessageParams m -> PluginDescriptor c -> Config -> HandleRequestResult -- | Parse the configuration to check if this plugin is globally enabled, -- and if the feature which handles this method is enabled. Perform -- sanity checks on the message to see whether the plugin handles this -- message in particular. This class is only used to determine whether a -- plugin can handle a specific request. Commands and rules do not use -- this logic to determine whether or not they are run. -- -- A common reason why a plugin won't handle a request even though it is -- enabled: * The plugin cannot handle requests associated with the -- specific URI * Since the implementation of cabal plugins HLS -- knows plugins specific to Haskell and specific to Cabal file -- descriptions * The resolve request is not routed to that specific -- plugin. Each resolve request needs to be routed to only one plugin. -- -- Strictly speaking, we are conflating two concepts here: * Dynamically -- enabled (e.g. on a per-message basis) * Statically enabled (e.g. by -- configuration in the lsp-client) * Strictly speaking, this might also -- change dynamically -- -- But there is no use to split it up into two different methods for now. handlesRequest :: (PluginMethod k m, HasTextDocument (MessageParams m) doc, HasUri doc Uri) => SMethod m -> MessageParams m -> PluginDescriptor c -> Config -> HandleRequestResult type PluginMethodHandler a m = a -> PluginId -> MessageParams m -> ExceptT PluginError (LspM Config) (MessageResult m) newtype PluginNotificationHandler a (m :: Method ClientToServer Notification) PluginNotificationHandler :: (PluginId -> a -> VFS -> MessageParams m -> LspM Config ()) -> PluginNotificationHandler a (m :: Method ClientToServer Notification) -- | Make a handler for plugins with no extra data mkPluginNotificationHandler :: PluginNotificationMethod m => SClientMethod (m :: Method ClientToServer Notification) -> PluginNotificationMethodHandler ideState m -> PluginNotificationHandlers ideState newtype PluginNotificationHandlers a PluginNotificationHandlers :: DMap IdeNotification (PluginNotificationHandler a) -> PluginNotificationHandlers a class PluginMethod Request m => PluginRequestMethod (m :: Method ClientToServer Request) -- | How to combine responses from different plugins. -- -- For example, for Hover requests, we might have multiple producers of -- Hover information. We do not want to decide which one to display to -- the user but instead allow to define how to merge two hover request -- responses into one glorious hover box. -- -- However, as sometimes only one handler of a request can realistically -- exist (such as TextDocumentFormatting), it is safe to just -- unconditionally report back one arbitrary result (arbitrary since it -- should only be one anyway). combineResponses :: PluginRequestMethod m => SMethod m -> Config -> ClientCapabilities -> MessageParams m -> NonEmpty (MessageResult m) -> MessageResult m -- | How to combine responses from different plugins. -- -- For example, for Hover requests, we might have multiple producers of -- Hover information. We do not want to decide which one to display to -- the user but instead allow to define how to merge two hover request -- responses into one glorious hover box. -- -- However, as sometimes only one handler of a request can realistically -- exist (such as TextDocumentFormatting), it is safe to just -- unconditionally report back one arbitrary result (arbitrary since it -- should only be one anyway). combineResponses :: (PluginRequestMethod m, Semigroup (MessageResult m)) => SMethod m -> Config -> ClientCapabilities -> MessageParams m -> NonEmpty (MessageResult m) -> MessageResult m getProcessID :: IO Int -- | Get the operating system process id for the running server instance. -- This should be the same for the lifetime of the instance, and -- different from that of any other currently running instance. getPid :: IO Text installSigUsr1Handler :: IO () -> IO () ($sel:lookupCommandProvider:IdePlugins_) :: IdePlugins ideState -> CommandId -> Maybe PluginId type ResolveFunction ideState a (m :: Method ClientToServer Request) = ideState -> PluginId -> MessageParams m -> Uri -> a -> ExceptT PluginError (LspM Config) (MessageResult m) -- | Make a handler for resolve methods. In here we take your provided -- ResolveFunction and turn it into a PluginHandlers. See Note [Resolve -- in PluginHandlers] mkResolveHandler :: forall ideState a m. (FromJSON a, PluginRequestMethod m, HasData_ (MessageParams m) (Maybe Value)) => SClientMethod m -> ResolveFunction ideState a m -> PluginHandlers ideState instance Data.Aeson.Types.ToJSON.ToJSON Ide.Types.CheckParents instance Data.Aeson.Types.FromJSON.FromJSON Ide.Types.CheckParents instance GHC.Generics.Generic Ide.Types.CheckParents instance GHC.Show.Show Ide.Types.CheckParents instance GHC.Classes.Ord Ide.Types.CheckParents instance GHC.Classes.Eq Ide.Types.CheckParents instance GHC.Classes.Eq Ide.Types.PluginConfig instance GHC.Show.Show Ide.Types.PluginConfig instance GHC.Classes.Ord Ide.Types.CommandId instance GHC.Classes.Eq Ide.Types.CommandId instance GHC.Read.Read Ide.Types.CommandId instance GHC.Show.Show Ide.Types.CommandId instance Data.Hashable.Class.Hashable Ide.Types.PluginId instance Data.Aeson.Types.FromJSON.FromJSON Ide.Types.PluginId instance Data.Aeson.Types.ToJSON.ToJSON Ide.Types.PluginId instance GHC.Classes.Ord Ide.Types.PluginId instance GHC.Classes.Eq Ide.Types.PluginId instance GHC.Read.Read Ide.Types.PluginId instance GHC.Show.Show Ide.Types.PluginId instance Data.Aeson.Types.FromJSON.FromJSON Ide.Types.PluginResolveData instance Data.Aeson.Types.ToJSON.ToJSON Ide.Types.PluginResolveData instance GHC.Show.Show Ide.Types.PluginResolveData instance GHC.Generics.Generic Ide.Types.PluginResolveData instance GHC.Classes.Eq Ide.Types.Config instance GHC.Show.Show Ide.Types.Config instance Data.Aeson.Types.FromJSON.FromJSON Ide.Types.FallbackCodeActionParams instance Data.Aeson.Types.ToJSON.ToJSON Ide.Types.FallbackCodeActionParams instance GHC.Generics.Generic Ide.Types.FallbackCodeActionParams instance GHC.Base.Semigroup (Ide.Types.IdePlugins a) instance GHC.Base.Monoid (Ide.Types.IdePlugins a) instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentCodeAction instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_CodeActionResolve instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDefinition instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentTypeDefinition instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDocumentHighlight instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentReferences instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceSymbol instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentCodeLens instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_CodeLensResolve instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentRename instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentHover instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDocumentSymbol instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_CompletionItemResolve instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentCompletion instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentFormatting instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentRangeFormatting instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentSemanticTokensFull instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentSemanticTokensFullDelta instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentPrepareCallHierarchy instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentSelectionRange instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentFoldingRange instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_CallHierarchyIncomingCalls instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_CallHierarchyOutgoingCalls instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceExecuteCommand instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Request ('Language.LSP.Protocol.Internal.Method.Method_CustomMethod m) instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidOpen instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidChange instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidSave instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidClose instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceDidChangeWatchedFiles instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceDidChangeWorkspaceFolders instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceDidChangeConfiguration instance Ide.Types.PluginMethod 'Language.LSP.Protocol.Message.Meta.Notification 'Language.LSP.Protocol.Internal.Method.Method_Initialized instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentCodeAction instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_CodeActionResolve instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDefinition instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentTypeDefinition instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDocumentHighlight instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentReferences instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceSymbol instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentCodeLens instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_CodeLensResolve instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentRename instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentHover instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDocumentSymbol instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_CompletionItemResolve instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentCompletion instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentFormatting instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentRangeFormatting instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentPrepareCallHierarchy instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentSelectionRange instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentFoldingRange instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_CallHierarchyIncomingCalls instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_CallHierarchyOutgoingCalls instance Ide.Types.PluginRequestMethod ('Language.LSP.Protocol.Internal.Method.Method_CustomMethod m) instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentSemanticTokensFull instance Ide.Types.PluginRequestMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentSemanticTokensFullDelta instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidOpen instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidChange instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidSave instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_TextDocumentDidClose instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceDidChangeWatchedFiles instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceDidChangeWorkspaceFolders instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_WorkspaceDidChangeConfiguration instance Ide.Types.PluginNotificationMethod 'Language.LSP.Protocol.Internal.Method.Method_Initialized instance Data.GADT.Internal.GEq Ide.Types.IdeMethod instance Data.GADT.Internal.GCompare Ide.Types.IdeMethod instance Data.GADT.Internal.GEq Ide.Types.IdeNotification instance Data.GADT.Internal.GCompare Ide.Types.IdeNotification instance GHC.Base.Semigroup (Ide.Types.PluginHandlers a) instance GHC.Base.Monoid (Ide.Types.PluginHandlers a) instance GHC.Base.Semigroup (Ide.Types.PluginNotificationHandlers a) instance GHC.Base.Monoid (Ide.Types.PluginNotificationHandlers a) instance (Language.LSP.Protocol.Types.Lens.HasTextDocument a doc, Language.LSP.Protocol.Types.Lens.HasUri doc Language.LSP.Protocol.Types.Uri.Uri) => Ide.Types.HasTracing a instance Ide.Types.HasTracing Data.Aeson.Types.Internal.Value instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.ExecuteCommandParams.ExecuteCommandParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.DidChangeWatchedFilesParams.DidChangeWatchedFilesParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.DidChangeWorkspaceFoldersParams.DidChangeWorkspaceFoldersParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.DidChangeConfigurationParams.DidChangeConfigurationParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.InitializeParams.InitializeParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.InitializedParams.InitializedParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.WorkspaceSymbolParams.WorkspaceSymbolParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.CallHierarchyIncomingCallsParams.CallHierarchyIncomingCallsParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.CallHierarchyOutgoingCallsParams.CallHierarchyOutgoingCallsParams instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.CodeAction.CodeAction instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.CodeLens.CodeLens instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.CompletionItem.CompletionItem instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.DocumentLink.DocumentLink instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.InlayHint.InlayHint instance Ide.Types.HasTracing Language.LSP.Protocol.Internal.Types.WorkspaceSymbol.WorkspaceSymbol instance Data.Aeson.Types.ToJSON.ToJSON Ide.Types.Config instance Data.Default.Class.Default Ide.Types.Config instance Data.String.IsString Ide.Types.PluginId instance Data.String.IsString Ide.Types.CommandId instance Data.Default.Class.Default Ide.Types.PluginConfig instance Data.Aeson.Types.ToJSON.ToJSON Ide.Types.PluginConfig instance GHC.Show.Show (Ide.Types.IdeCommand st) instance GHC.Base.Semigroup Ide.Types.DynFlagsModifications instance GHC.Base.Monoid Ide.Types.DynFlagsModifications -- | 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 -- | When provided with both a codeAction provider and an affiliated -- codeAction resolve provider, this function creates a handler that -- automatically uses your resolve provider to fill out you original -- codeAction if the client doesn't have codeAction resolve support. This -- means you don't have to check whether the client supports resolve and -- act accordingly in your own providers. mkCodeActionHandlerWithResolve :: forall ideState a. FromJSON a => Recorder (WithPriority Log) -> PluginMethodHandler ideState 'Method_TextDocumentCodeAction -> ResolveFunction ideState a 'Method_CodeActionResolve -> PluginHandlers ideState -- | When provided with both a codeAction provider with a data field and a -- resolve provider, this function creates a handler that creates a -- command that uses your resolve if the client doesn't have code action -- resolve support. This means you don't have to check whether the client -- supports resolve and act accordingly in your own providers. see Note -- [Code action resolve fallback to commands] Also: This helper only -- works with workspace edits, not commands. Any command set either in -- the original code action or in the resolve will be ignored. mkCodeActionWithResolveAndCommand :: forall ideState a. FromJSON a => Recorder (WithPriority Log) -> PluginId -> PluginMethodHandler ideState 'Method_TextDocumentCodeAction -> ResolveFunction ideState a 'Method_CodeActionResolve -> ([PluginCommand ideState], PluginHandlers ideState) instance GHC.Show.Show Ide.Plugin.Resolve.WithURI instance GHC.Generics.Generic Ide.Plugin.Resolve.WithURI instance Data.Aeson.Types.ToJSON.ToJSON Ide.Plugin.Resolve.WithURI instance Data.Aeson.Types.FromJSON.FromJSON Ide.Plugin.Resolve.WithURI instance Prettyprinter.Internal.Pretty Ide.Plugin.Resolve.Log module Ide.Plugin.Config -- | Given a DidChangeConfigurationNotification message, this function -- returns the parsed Config object if possible. getConfigFromNotification :: IdePlugins s -> Config -> Value -> Either Text Config -- | We (initially anyway) mirror the hie configuration, so that existing -- clients can simply switch executable and not have any nasty surprises. -- There will initially be surprises relating to config options being -- ignored though. data Config Config :: CheckParents -> !Bool -> !Text -> !Text -> !Int -> !Map PluginId PluginConfig -> Config [$sel:checkParents:Config] :: Config -> CheckParents [$sel:checkProject:Config] :: Config -> !Bool [$sel:formattingProvider:Config] :: Config -> !Text [$sel:cabalFormattingProvider:Config] :: Config -> !Text [$sel:maxCompletions:Config] :: Config -> !Int [$sel:plugins:Config] :: Config -> !Map PluginId PluginConfig parseConfig :: IdePlugins s -> Config -> Value -> Parser Config -- | 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. This -- provides a regular naming scheme for all plugin config. data PluginConfig PluginConfig :: !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Object -> PluginConfig [$sel:plcGlobalOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCallHierarchyOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCodeActionsOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCodeLensOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcDiagnosticsOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcHoverOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcSymbolsOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcCompletionOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcRenameOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcSelectionRangeOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcFoldingRangeOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcSemanticTokensOn:PluginConfig] :: PluginConfig -> !Bool [$sel:plcConfig:PluginConfig] :: PluginConfig -> !Object data CheckParents NeverCheck :: CheckParents CheckOnSave :: CheckParents AlwaysCheck :: CheckParents module Ide.PluginUtils -- | Extend to the line below and above to replace newline character. -- --
--   >>> normalize (Range (Position 5 5) (Position 5 10))
--   Range (Position 5 0) (Position 6 0)
--   
normalize :: Range -> Range -- | Extend Range to the start of the next line. -- --
--   >>> extendNextLine (Range (Position 5 5) (Position 5 10))
--   Range (Position 5 5) (Position 6 0)
--   
extendNextLine :: Range -> Range -- | Extend Range to the start of the current line. -- --
--   >>> extendLineStart (Range (Position 5 5) (Position 5 10))
--   Range (Position 5 0) (Position 5 10)
--   
extendLineStart :: Range -> Range -- | Extend Range to include the start of the first line and start -- of the next line of the last line. -- -- Caveat: It always extend the last line to the beginning of next line, -- even when the last position is at column 0. This is to keep the -- compatibility with the implementation of old function -- extractRange. -- --
--   >>> extendToFullLines (Range (Position 5 5) (Position 5 10))
--   Range (Position 5 0) (Position 6 0)
--   
-- --
--   >>> extendToFullLines (Range (Position 5 5) (Position 7 2))
--   Range (Position 5 0) (Position 8 0)
--   
-- --
--   >>> extendToFullLines (Range (Position 5 5) (Position 7 0))
--   Range (Position 5 0) (Position 8 0)
--   
extendToFullLines :: Range -> Range data WithDeletions IncludeDeletions :: WithDeletions SkipDeletions :: WithDeletions getProcessID :: IO Int makeDiffTextEdit :: Text -> Text -> [TextEdit] makeDiffTextEditAdditive :: Text -> Text -> [TextEdit] -- | Generate a WorkspaceEdit value from a pair of source Text diffText :: ClientCapabilities -> (VersionedTextDocumentIdentifier, Text) -> Text -> WithDeletions -> WorkspaceEdit -- | A pure version of diffText for testing diffText' :: Bool -> (VersionedTextDocumentIdentifier, Text) -> Text -> WithDeletions -> WorkspaceEdit pluginDescToIdePlugins :: [PluginDescriptor ideState] -> IdePlugins ideState idePluginsToPluginDesc :: IdePlugins ideState -> [PluginDescriptor ideState] -- | Returns the current client configuration. It is not wise to -- permanently cache the returned value of this function, as clients can -- at runtime change their configuration. getClientConfig :: MonadLsp Config m => m Config -- | Returns the current plugin configuration. It is not wise to -- permanently cache the returned value of this function, as clients can -- change their configuration at runtime. getPluginConfig :: MonadLsp Config m => PluginDescriptor c -> m PluginConfig -- | Lookup the current config for a plugin configForPlugin :: Config -> PluginDescriptor c -> PluginConfig -- | Parse the configuration to check if this plugin is globally enabled, -- and if the feature which handles this method is enabled. Perform -- sanity checks on the message to see whether the plugin handles this -- message in particular. This class is only used to determine whether a -- plugin can handle a specific request. Commands and rules do not use -- this logic to determine whether or not they are run. -- -- A common reason why a plugin won't handle a request even though it is -- enabled: * The plugin cannot handle requests associated with the -- specific URI * Since the implementation of cabal plugins HLS -- knows plugins specific to Haskell and specific to Cabal file -- descriptions * The resolve request is not routed to that specific -- plugin. Each resolve request needs to be routed to only one plugin. -- -- Strictly speaking, we are conflating two concepts here: * Dynamically -- enabled (e.g. on a per-message basis) * Statically enabled (e.g. by -- configuration in the lsp-client) * Strictly speaking, this might also -- change dynamically -- -- But there is no use to split it up into two different methods for now. handlesRequest :: PluginMethod k m => SMethod m -> MessageParams m -> PluginDescriptor c -> Config -> HandleRequestResult -- | Extracts exact matching text in the range. extractTextInRange :: Range -> Text -> Text -- | Gets the range that covers the entire text fullRange :: Text -> Range mkLspCommand :: PluginId -> CommandId -> Text -> Maybe [Value] -> Command mkLspCmdId :: Text -> PluginId -> CommandId -> Text -- | Get the operating system process id for the running server instance. -- This should be the same for the lifetime of the instance, and -- different from that of any other currently running instance. getPid :: IO Text allLspCmdIds :: Text -> [(PluginId, [PluginCommand ideState])] -> [Text] allLspCmdIds' :: Text -> IdePlugins ideState -> [Text] installSigUsr1Handler :: IO () -> IO () subRange :: Range -> Range -> Bool positionInRange :: Position -> Range -> Bool -- | Returns the value of a property defined by the current plugin. usePropertyLsp :: (HasProperty s k t r, MonadLsp Config m) => KeyNameProxy s -> PluginDescriptor c -> Properties r -> m (ToHsType t) -- | Unescape printable escape sequences within double quotes. This is -- useful if you have to call show indirectly, and it escapes some -- characters which you would prefer to display as is. unescape :: Text -> Text instance GHC.Classes.Eq Ide.PluginUtils.WithDeletions module Ide.Plugin.ConfigUtils -- | Generates a default Config, but remains only effective items pluginsToDefaultConfig :: IdePlugins a -> Value -- | Generates json schema used in haskell vscode extension Similar to -- pluginsToDefaultConfig but simpler, since schema has a flatten -- structure pluginsToVSCodeExtensionSchema :: IdePlugins a -> Value