lsp-2.7.0.1: Haskell library for the Microsoft Language Server Protocol

Safe Haskell | None
Language | GHC2021

Language.LSP.Server

Contents

- Handlers
- LspT and LspM
- Config
- Shutdown
- VFS
- Diagnostics
- Progress
- Dynamic registration

Synopsis

- data LspServerLog
  - = LspProcessingLog LspProcessingLog
  - | DecodeInitializeError String
  - | HeaderParseFail [String] String
  - | EOF
  - | Starting
  - | ParsedMsg Text
  - | SendMsg Text
- runServer :: ServerDefinition config -> IO Int
- runServerWith :: LogAction IO (WithSeverity LspServerLog) -> LogAction (LspM config) (WithSeverity LspServerLog) -> IO ByteString -> (ByteString -> IO ()) -> ServerDefinition config -> IO Int
- runServerWithHandles :: LogAction IO (WithSeverity LspServerLog) -> LogAction (LspM config) (WithSeverity LspServerLog) -> Handle -> Handle -> ServerDefinition config -> IO Int
- data VFSData = VFSData {
  - vfsData :: !VFS
  - reverseMap :: !(Map FilePath FilePath)
  }
- data ServerDefinition config = ServerDefinition {
  - defaultConfig :: config
  - configSection :: Text
  - parseConfig :: config -> Value -> Either Text config
  - onConfigChange :: config -> m ()
  - doInitialize :: LanguageContextEnv config -> TMessage 'Method_Initialize -> IO (Either (TResponseError 'Method_Initialize) a)
  - staticHandlers :: ClientCapabilities -> Handlers m
  - interpretHandler :: a -> m <~> IO
  - options :: Options
  }
- data Handlers (m :: Type -> Type) = Handlers {
  - reqHandlers :: !(SMethodMap (ClientMessageHandler m 'Request))
  - notHandlers :: !(SMethodMap (ClientMessageHandler m 'Notification))
  }
- type family Handler (f :: Type -> Type) (m :: Method from t) = (result :: Type) | result -> from t f m where ...
- transmuteHandlers :: forall (m :: Type -> Type) (n :: Type -> Type). (m <~> n) -> Handlers m -> Handlers n
- mapHandlers :: forall (m :: Type -> Type) (n :: Type -> Type). (forall (a :: Method 'ClientToServer 'Request). Handler m a -> Handler n a) -> (forall (a :: Method 'ClientToServer 'Notification). Handler m a -> Handler n a) -> Handlers m -> Handlers n
- notificationHandler :: forall (m :: Method 'ClientToServer 'Notification) (f :: Type -> Type). SMethod m -> Handler f m -> Handlers f
- requestHandler :: forall (m :: Method 'ClientToServer 'Request) (f :: Type -> Type). SMethod m -> Handler f m -> Handlers f
- newtype ClientMessageHandler (f :: Type -> Type) (t :: MessageKind) (m :: Method 'ClientToServer t) = ClientMessageHandler (Handler f m)
- data Options = Options {
  - optTextDocumentSync :: Maybe TextDocumentSyncOptions
  - optCompletionTriggerCharacters :: Maybe [Char]
  - optCompletionAllCommitCharacters :: Maybe [Char]
  - optSignatureHelpTriggerCharacters :: Maybe [Char]
  - optSignatureHelpRetriggerCharacters :: Maybe [Char]
  - optCodeActionKinds :: Maybe [CodeActionKind]
  - optDocumentOnTypeFormattingTriggerCharacters :: Maybe (NonEmpty Char)
  - optExecuteCommandCommands :: Maybe [Text]
  - optServerInfo :: Maybe ServerInfo
  - optSupportClientInitiatedProgress :: Bool
  - optProgressStartDelay :: Int
  - optProgressUpdateDelay :: Int
  }
- defaultOptions :: Options
- newtype LspT config (m :: Type -> Type) a = LspT {
  - unLspT :: ReaderT (LanguageContextEnv config) m a
  }
- type LspM config = LspT config IO
- class MonadUnliftIO m => MonadLsp config (m :: Type -> Type) | m -> config where
  - getLspEnv :: m (LanguageContextEnv config)
- runLspT :: LanguageContextEnv config -> LspT config m a -> m a
- data LanguageContextEnv config = LanguageContextEnv {
  - resHandlers :: !(Handlers IO)
  - resConfigSection :: Text
  - resParseConfig :: !(config -> Value -> Either Text config)
  - resOnConfigChange :: !(config -> IO ())
  - resSendMessage :: !(FromServerMessage -> IO ())
  - resState :: !(LanguageContextState config)
  - resClientCapabilities :: !ClientCapabilities
  - resRootPath :: !(Maybe FilePath)
  - resProgressStartDelay :: Int
  - resProgressUpdateDelay :: Int
  }
- data (m :: k -> Type) <~> (n :: k -> Type) = Iso {
  - forward :: forall (a :: k). m a -> n a
  - backward :: forall (a :: k). n a -> m a
  }
- getClientCapabilities :: MonadLsp config m => m ClientCapabilities
- getConfig :: MonadLsp config m => m config
- setConfig :: MonadLsp config m => config -> m ()
- getRootPath :: MonadLsp config m => m (Maybe FilePath)
- getWorkspaceFolders :: MonadLsp config m => m (Maybe [WorkspaceFolder])
- sendRequest :: forall (m :: Method 'ServerToClient 'Request) f config. MonadLsp config f => SServerMethod m -> MessageParams m -> (Either (TResponseError m) (MessageResult m) -> f ()) -> f (LspId m)
- sendNotification :: forall (m :: Method 'ServerToClient 'Notification) f config. MonadLsp config f => SServerMethod m -> MessageParams m -> f ()
- requestConfigUpdate :: m ~ LspM config => LogAction m (WithSeverity LspCoreLog) -> m ()
- tryChangeConfig :: m ~ LspM config => LogAction m (WithSeverity LspCoreLog) -> Value -> m ()
- isShuttingDown :: m ~ LspM config => m Bool
- waitShuttingDown :: m ~ LspM config => m ()
- getVirtualFile :: MonadLsp config m => NormalizedUri -> m (Maybe VirtualFile)
- getVirtualFiles :: MonadLsp config m => m VFS
- persistVirtualFile :: MonadLsp config m => LogAction m (WithSeverity VfsLog) -> FilePath -> NormalizedUri -> m (Maybe FilePath)
- getVersionedTextDoc :: MonadLsp config m => TextDocumentIdentifier -> m VersionedTextDocumentIdentifier
- reverseFileMap :: MonadLsp config m => m (FilePath -> FilePath)
- snapshotVirtualFiles :: LanguageContextEnv c -> STM VFS
- publishDiagnostics :: MonadLsp config m => Int -> NormalizedUri -> Maybe Int32 -> DiagnosticsBySource -> m ()
- flushDiagnosticsBySource :: MonadLsp config m => Int -> Maybe Text -> m ()
- withProgress :: MonadLsp c m => Text -> Maybe ProgressToken -> ProgressCancellable -> ((ProgressAmount -> m ()) -> m a) -> m a
- withIndefiniteProgress :: MonadLsp c m => Text -> Maybe ProgressToken -> ProgressCancellable -> ((Text -> m ()) -> m a) -> m a
- data ProgressAmount = ProgressAmount (Maybe UInt) (Maybe Text)
- data ProgressCancellable
  - = Cancellable
  - | NotCancellable
- data ProgressCancelledException
- registerCapability :: forall f (t :: MessageKind) (m :: Method 'ClientToServer t) config. MonadLsp config f => LogAction f (WithSeverity LspCoreLog) -> SClientMethod m -> RegistrationOptions m -> Handler f m -> f (Maybe (RegistrationToken m))
- unregisterCapability :: forall {t :: MessageKind} config f (m :: Method 'ClientToServer t). MonadLsp config f => RegistrationToken m -> f ()
- data RegistrationToken (m :: Method 'ClientToServer t)
- reverseSortEdit :: WorkspaceEdit -> WorkspaceEdit

# Documentation

data LspServerLog #

Constructors

LspProcessingLog LspProcessingLog |
DecodeInitializeError String |
HeaderParseFail [String] String |
EOF |
Starting |
ParsedMsg Text |
SendMsg Text |

#### Instances

Instances details

Show LspServerLog # |
Instance details Defined in Language.LSP.Server.Control Methods showsPrec :: Int -> LspServerLog -> ShowS # show :: LspServerLog -> String # showList :: [LspServerLog] -> ShowS #
Pretty LspServerLog # |
Instance details Defined in Language.LSP.Server.Control Methods pretty :: LspServerLog -> Doc ann # prettyList :: [LspServerLog] -> Doc ann #

runServer :: ServerDefinition config -> IO Int #

Convenience function for `runServerWithHandles` which: (1) reads from stdin; (2) writes to stdout; and (3) logs to stderr and to the client, with some basic filtering.

runServerWith #

Arguments

:: LogAction IO (WithSeverity LspServerLog) | The logger to use outside the main body of the server where we can't assume the ability to send messages.
-> LogAction (LspM config) (WithSeverity LspServerLog) | The logger to use once the server has started and can successfully send messages.
-> IO ByteString | Client input.
-> (ByteString -> IO ()) | Function to provide output to.
-> ServerDefinition config |
-> IO Int |

Starts listening and sending requests and responses using the specified I/O.

runServerWithHandles #

Arguments

:: LogAction IO (WithSeverity LspServerLog) | The logger to use outside the main body of the server where we can't assume the ability to send messages.
-> LogAction (LspM config) (WithSeverity LspServerLog) | The logger to use once the server has started and can successfully send messages.
-> Handle | Handle to read client input from.
-> Handle | Handle to write output to.
-> ServerDefinition config |
-> IO Int |

Starts a language server over the specified handles. This function will return once the `exit` notification is received.

data VFSData #

Constructors

VFSData |
Fields vfsData :: !VFS reverseMap :: !(Map FilePath FilePath)

data ServerDefinition config #

Contains all the callbacks to use for initialized the language server. it is parameterized over a config type variable representing the type for the specific configuration data the language server needs to use.

Constructors

ServerDefinition |
- Fields defaultConfig :: config The default value we initialize the config variable to. configSection :: Text The "config section" that this server uses. This is used to identify the settings that are relevant to the server. parseConfig :: config -> Value -> Either Text config `parseConfig oldConfig newConfigObject` is called whenever we get updated configuration from the client. `parseConfig` is called on the object corresponding to the server's config section, it should not itself try to look for the config section. Note that the `Value` may represent only a partial object in the case where we are handling a `workspace/didChangeConfiguration` request where the client sends only the changed settings. This is also the main circumstance where the old configuration argument is useful. It is generally fine for servers to ignore this case and just assume that the `Value` represents a full new config and ignore the old configuration. This will only be problematic in the case of clients which behave as above and *also* don't support `workspace/configuration`, which is discouraged. onConfigChange :: config -> m () This callback is called any time the configuration is updated, with the new config. Servers that want to react to config changes should provide a callback here, it is not sufficient to just add e.g. a `workspace/didChangeConfiguration` handler. doInitialize :: LanguageContextEnv config -> TMessage 'Method_Initialize -> IO (Either (TResponseError 'Method_Initialize) a) Called *after* receiving the `initialize` request and *before* returning the response. This callback will be invoked to offer the language server implementation the chance to create any processes or start new threads that may be necessary for the server lifecycle. It can also return an error in the initialization if necessary. staticHandlers :: ClientCapabilities -> Handlers m Handlers for any methods you want to statically support. The handlers here cannot be unregistered during the server's lifetime and will be registered statically in the initialize request. The handlers provided can depend on the client capabilities, which are static across the lifetime of the server. interpretHandler :: a -> m <~> IO How to run the handlers in your own monad of choice, `m`. It is passed the result of `doInitialize`, so typically you will want to thread along the `LanguageContextEnv` as well as any other state you need to run your monad. `m` should most likely be built on top of `LspT`.
       ServerDefinition { ...
       , doInitialize = env _req -> pure $ Right env
       , interpretHandler = env -> Iso
          (runLspT env) -- how to convert from IO ~> m
          liftIO        -- how to convert from m ~> IO
       }
options :: Options Configurable options for the server's capabilities.

# Handlers

data Handlers (m :: Type -> Type) #

A mapping from methods to the static `Handler`s that should be used to handle responses when they come in from the client. To build up a `Handlers`, you should `mconcat` a list of `notificationHandler` and `requestHandler`s:

    mconcat [
      notificationHandler SInitialized $ notif -> pure ()
    , requestHandler STextDocumentHover $ req responder -> pure ()
    ]

Constructors

Handlers |
Fields reqHandlers :: !(SMethodMap (ClientMessageHandler m 'Request)) notHandlers :: !(SMethodMap (ClientMessageHandler m 'Notification))

#### Instances

Instances details

Monoid (Handlers config) # |
Instance details Defined in Language.LSP.Server.Core Methods mempty :: Handlers config # mappend :: Handlers config -> Handlers config -> Handlers config # mconcat :: [Handlers config] -> Handlers config #
Semigroup (Handlers config) # |
Instance details Defined in Language.LSP.Server.Core Methods (<>) :: Handlers config -> Handlers config -> Handlers config # sconcat :: NonEmpty (Handlers config) -> Handlers config # stimes :: Integral b => b -> Handlers config -> Handlers config #

type family Handler (f :: Type -> Type) (m :: Method from t) = (result :: Type) | result -> from t f m where ... #

The type of a handler that handles requests and notifications coming in from the server or client

Equations

Handler f (m :: Method _from 'Request) = TRequestMessage m -> (Either (TResponseError m) (MessageResult m) -> f ()) -> f () |
Handler f (m :: Method _from 'Notification) = TNotificationMessage m -> f () |

transmuteHandlers :: forall (m :: Type -> Type) (n :: Type -> Type). (m <~> n) -> Handlers m -> Handlers n #

mapHandlers :: forall (m :: Type -> Type) (n :: Type -> Type). (forall (a :: Method 'ClientToServer 'Request). Handler m a -> Handler n a) -> (forall (a :: Method 'ClientToServer 'Notification). Handler m a -> Handler n a) -> Handlers m -> Handlers n #

notificationHandler :: forall (m :: Method 'ClientToServer 'Notification) (f :: Type -> Type). SMethod m -> Handler f m -> Handlers f #

requestHandler :: forall (m :: Method 'ClientToServer 'Request) (f :: Type -> Type). SMethod m -> Handler f m -> Handlers f #

newtype ClientMessageHandler (f :: Type -> Type) (t :: MessageKind) (m :: Method 'ClientToServer t) #

Wrapper to restrict `Handler`s to ClientToServer' `Method`s

Constructors

ClientMessageHandler (Handler f m) |

data Options #

Options that the server may configure. If you set handlers for some requests, you may need to set some of these options.

Constructors

Options |
Fields optTextDocumentSync :: Maybe TextDocumentSyncOptions optCompletionTriggerCharacters :: Maybe [Char] The characters that trigger completion automatically. optCompletionAllCommitCharacters :: Maybe [Char] The list of all possible characters that commit a completion. This field can be used if clients don't support individual commit characters per completion item. See `_commitCharactersSupport`. optSignatureHelpTriggerCharacters :: Maybe [Char] The characters that trigger signature help automatically. optSignatureHelpRetriggerCharacters :: Maybe [Char] List of characters that re-trigger signature help. These trigger characters are only active when signature help is already showing. All trigger characters are also counted as re-trigger characters. optCodeActionKinds :: Maybe [CodeActionKind] CodeActionKinds that this server may return. The list of kinds may be generic, such as `Refactor`, or the server may list out every specific kind they provide. optDocumentOnTypeFormattingTriggerCharacters :: Maybe (NonEmpty Char) The list of characters that triggers on type formatting. If you set `documentOnTypeFormattingHandler`, you **must** set this. The first character is mandatory, so a `NonEmpty` should be passed. optExecuteCommandCommands :: Maybe [Text] The commands to be executed on the server. If you set `executeCommandHandler`, you **must** set this. optServerInfo :: Maybe ServerInfo Information about the server that can be advertised to the client. optSupportClientInitiatedProgress :: Bool Whether or not to support client-initiated progress. optProgressStartDelay :: Int The delay before starting a progress reporting session, in microseconds optProgressUpdateDelay :: Int The delay between sending progress updates, in microseconds

#### Instances

Instances details

Default Options # |
Instance details Defined in Language.LSP.Server.Core Methods def :: Options #

defaultOptions :: Options #

# LspT and LspM

newtype LspT config (m :: Type -> Type) a #

Constructors

LspT |
Fields unLspT :: ReaderT (LanguageContextEnv config) m a

#### Instances

Instances details

MonadUnliftIO m => MonadLsp config (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods getLspEnv :: LspT config m (LanguageContextEnv config) #
MonadTrans (LspT config) # |
Instance details Defined in Language.LSP.Server.Core Methods lift :: Monad m => m a -> LspT config m a #
MonadIO m => MonadIO (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods liftIO :: IO a -> LspT config m a #
MonadCatch m => MonadCatch (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods catch :: (HasCallStack, Exception e) => LspT config m a -> (e -> LspT config m a) -> LspT config m a #
MonadMask m => MonadMask (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods mask :: HasCallStack => ((forall a. LspT config m a -> LspT config m a) -> LspT config m b) -> LspT config m b # uninterruptibleMask :: HasCallStack => ((forall a. LspT config m a -> LspT config m a) -> LspT config m b) -> LspT config m b # generalBracket :: HasCallStack => LspT config m a -> (a -> ExitCase b -> LspT config m c) -> (a -> LspT config m b) -> LspT config m (b, c) #
MonadThrow m => MonadThrow (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods throwM :: (HasCallStack, Exception e) => e -> LspT config m a #
Applicative m => Applicative (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods pure :: a -> LspT config m a # (<*>) :: LspT config m (a -> b) -> LspT config m a -> LspT config m b # liftA2 :: (a -> b -> c) -> LspT config m a -> LspT config m b -> LspT config m c # (*>) :: LspT config m a -> LspT config m b -> LspT config m b # (<*) :: LspT config m a -> LspT config m b -> LspT config m a #
Functor m => Functor (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods fmap :: (a -> b) -> LspT config m a -> LspT config m b # (<$) :: a -> LspT config m b -> LspT config m a #
Monad m => Monad (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods (>>=) :: LspT config m a -> (a -> LspT config m b) -> LspT config m b # (>>) :: LspT config m a -> LspT config m b -> LspT config m b # return :: a -> LspT config m a #
MonadFix m => MonadFix (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods mfix :: (a -> LspT config m a) -> LspT config m a #
MonadUnliftIO m => MonadUnliftIO (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods withRunInIO :: ((forall a. LspT config m a -> IO a) -> IO b) -> LspT config m b #
(Applicative m, Monoid a) => Monoid (LspT config m a) # |
Instance details Defined in Language.LSP.Server.Core Methods mempty :: LspT config m a # mappend :: LspT config m a -> LspT config m a -> LspT config m a # mconcat :: [LspT config m a] -> LspT config m a #
(Applicative m, Semigroup a) => Semigroup (LspT config m a) # |
Instance details Defined in Language.LSP.Server.Core Methods (<>) :: LspT config m a -> LspT config m a -> LspT config m a # sconcat :: NonEmpty (LspT config m a) -> LspT config m a # stimes :: Integral b => b -> LspT config m a -> LspT config m a #

type LspM config = LspT config IO #

class MonadUnliftIO m => MonadLsp config (m :: Type -> Type) | m -> config where #

Methods

getLspEnv :: m (LanguageContextEnv config) #

#### Instances

Instances details

MonadLsp c m => MonadLsp c (IdentityT m) # |
Instance details Defined in Language.LSP.Server.Core Methods getLspEnv :: IdentityT m (LanguageContextEnv c) #
MonadLsp c m => MonadLsp c (ReaderT r m) # |
Instance details Defined in Language.LSP.Server.Core Methods getLspEnv :: ReaderT r m (LanguageContextEnv c) #
MonadUnliftIO m => MonadLsp config (LspT config m) # |
Instance details Defined in Language.LSP.Server.Core Methods getLspEnv :: LspT config m (LanguageContextEnv config) #

runLspT :: LanguageContextEnv config -> LspT config m a -> m a #

data LanguageContextEnv config #

Constructors

LanguageContextEnv |
Fields resHandlers :: !(Handlers IO) resConfigSection :: Text resParseConfig :: !(config -> Value -> Either Text config) resOnConfigChange :: !(config -> IO ()) resSendMessage :: !(FromServerMessage -> IO ()) resState :: !(LanguageContextState config) resClientCapabilities :: !ClientCapabilities resRootPath :: !(Maybe FilePath) resProgressStartDelay :: Int The delay before starting a progress reporting session, in microseconds resProgressUpdateDelay :: Int The delay between sending progress updates, in microseconds

data (m :: k -> Type) <~> (n :: k -> Type) #

How to convert two isomorphic data structures between each other.

Constructors

Iso |
Fields forward :: forall (a :: k). m a -> n a backward :: forall (a :: k). n a -> m a

getClientCapabilities :: MonadLsp config m => m ClientCapabilities #

getConfig :: MonadLsp config m => m config #

The current configuration from the client as set via the `initialize` and `workspace/didChangeConfiguration` requests, as well as by calls to `setConfig`.

setConfig :: MonadLsp config m => config -> m () #

getRootPath :: MonadLsp config m => m (Maybe FilePath) #

getWorkspaceFolders :: MonadLsp config m => m (Maybe [WorkspaceFolder]) #

The current workspace folders, if the client supports workspace folders.

sendRequest :: forall (m :: Method 'ServerToClient 'Request) f config. MonadLsp config f => SServerMethod m -> MessageParams m -> (Either (TResponseError m) (MessageResult m) -> f ()) -> f (LspId m) #

sendNotification :: forall (m :: Method 'ServerToClient 'Notification) f config. MonadLsp config f => SServerMethod m -> MessageParams m -> f () #

# Config

requestConfigUpdate :: m ~ LspM config => LogAction m (WithSeverity LspCoreLog) -> m () #

Send a `worksapce/configuration` request to update the server's config.

This is called automatically in response to `workspace/didChangeConfiguration` notifications from the client, so should not normally be called manually.

tryChangeConfig :: m ~ LspM config => LogAction m (WithSeverity LspCoreLog) -> Value -> m () #

Given a new config object, try to update our config with it.

# Shutdown

isShuttingDown :: m ~ LspM config => m Bool #

Checks if the server has received a `shutdown` request.

waitShuttingDown :: m ~ LspM config => m () #

Blocks until the server receives a `shutdown` request.

# VFS

getVirtualFile :: MonadLsp config m => NormalizedUri -> m (Maybe VirtualFile) #

Return the `VirtualFile` associated with a given `NormalizedUri`, if there is one.

getVirtualFiles :: MonadLsp config m => m VFS #

persistVirtualFile :: MonadLsp config m => LogAction m (WithSeverity VfsLog) -> FilePath -> NormalizedUri -> m (Maybe FilePath) #

Dump the current text for a given VFS file to a file in the given directory and return the path to the file.

getVersionedTextDoc :: MonadLsp config m => TextDocumentIdentifier -> m VersionedTextDocumentIdentifier #

Given a text document identifier, annotate it with the latest version.

reverseFileMap :: MonadLsp config m => m (FilePath -> FilePath) #

If the contents of a VFS has been dumped to a temporary file, map the temporary file name back to the original one.

snapshotVirtualFiles :: LanguageContextEnv c -> STM VFS #

Take an atomic snapshot of the current state of the virtual file system.

# Diagnostics

publishDiagnostics :: MonadLsp config m => Int -> NormalizedUri -> Maybe Int32 -> DiagnosticsBySource -> m () #

Aggregate all diagnostics pertaining to a particular version of a document, by source, and sends a `textDocument/publishDiagnostics` notification with the total (limited by the first parameter) whenever it is updated.

flushDiagnosticsBySource #

Arguments

:: MonadLsp config m |
=> Int | Max number of diagnostics to send
-> Maybe Text |
-> m () |

Remove all diagnostics from a particular source, and send the updates to the client.

# Progress

withProgress #

Arguments

:: MonadLsp c m |
=> Text | The title of the progress operation
-> Maybe ProgressToken | The progress token provided by the client in the method params, if any
-> ProgressCancellable | Whether or not this operation is cancellable. If true, the user will be shown a button to allow cancellation. Note that requests can still be cancelled even if this is not set.
-> ((ProgressAmount -> m ()) -> m a) | An update function to pass progress updates to
-> m a |

Wrapper for reporting progress to the client during a long running task.

withIndefiniteProgress #

Arguments

:: MonadLsp c m |
=> Text | The title of the progress operation
-> Maybe ProgressToken | The progress token provided by the client in the method params, if any
-> ProgressCancellable | Whether or not this operation is cancellable. If true, the user will be shown a button to allow cancellation. Note that requests can still be cancelled even if this is not set.
-> ((Text -> m ()) -> m a) | An update function to pass progress updates to
-> m a |

Same as `withProgress`, but for processes that do not report the precentage complete.

data ProgressAmount #

A package indicating the percentage of progress complete and a an optional message to go with it during a `withProgress`

Since: 0.10.0.0

Constructors

ProgressAmount (Maybe UInt) (Maybe Text) |

data ProgressCancellable #

Whether or not the user should be able to cancel a `withProgress`/`withIndefiniteProgress` session

Since: 0.11.0.0

Constructors

Cancellable |
NotCancellable |

data ProgressCancelledException #

Thrown if the user cancels a `Cancellable` `withProgress` `withIndefiniteProgress` session

Since: 0.11.0.0

#### Instances

Instances details

Exception ProgressCancelledException # |
Instance details Defined in Language.LSP.Server.Progress Methods toException :: ProgressCancelledException -> SomeException # fromException :: SomeException -> Maybe ProgressCancelledException # displayException :: ProgressCancelledException -> String # backtraceDesired :: ProgressCancelledException -> Bool #
Show ProgressCancelledException # |
Instance details Defined in Language.LSP.Server.Progress Methods showsPrec :: Int -> ProgressCancelledException -> ShowS # show :: ProgressCancelledException -> String # showList :: [ProgressCancelledException] -> ShowS #

# Dynamic registration

registerCapability :: forall f (t :: MessageKind) (m :: Method 'ClientToServer t) config. MonadLsp config f => LogAction f (WithSeverity LspCoreLog) -> SClientMethod m -> RegistrationOptions m -> Handler f m -> f (Maybe (RegistrationToken m)) #

Sends a `client/registerCapability` request and dynamically registers a `Method` with a `Handler`. Returns `Nothing` if the client does not support dynamic registration for the specified method, otherwise a `RegistrationToken` which can be used to unregister it later.

unregisterCapability :: forall {t :: MessageKind} config f (m :: Method 'ClientToServer t). MonadLsp config f => RegistrationToken m -> f () #

Sends a `client/unregisterCapability` request and removes the handler for that associated registration.

data RegistrationToken (m :: Method 'ClientToServer t) #

reverseSortEdit :: WorkspaceEdit -> WorkspaceEdit #

The changes in a workspace edit should be applied from the end of the file toward the start. Sort them into this order.