Safe Haskell | None |
---|---|
Language | Haskell2010 |
- handleRequest :: Show c => InitializeCallback c -> TVar (LanguageContextData c) -> ByteString -> ByteString -> IO ()
- data LanguageContextData a = LanguageContextData {
- resSeqDebugContextData :: !Int
- resRootPath :: !(Maybe FilePath)
- resHandlers :: !Handlers
- resOptions :: !Options
- resSendResponse :: !SendFunc
- resVFS :: !VFS
- resDiagnostics :: !DiagnosticStore
- resConfig :: !(Maybe a)
- resLspId :: !(TVar Int)
- resLspFuncs :: LspFuncs a
- type Handler b = b -> IO ()
- type InitializeCallback c = (DidChangeConfigurationNotification -> Either Text c, LspFuncs c -> IO (Maybe ResponseError))
- data LspFuncs c = LspFuncs {
- clientCapabilities :: !ClientCapabilities
- config :: !(IO (Maybe c))
- sendFunc :: !SendFunc
- getVirtualFileFunc :: !(Uri -> IO (Maybe VirtualFile))
- publishDiagnosticsFunc :: !PublishDiagnosticsFunc
- flushDiagnosticsBySourceFunc :: !FlushDiagnosticsBySourceFunc
- getNextReqId :: !(IO LspId)
- type SendFunc = forall a. ToJSON a => a -> IO ()
- data Handlers = Handlers {
- hoverHandler :: !(Maybe (Handler HoverRequest))
- completionHandler :: !(Maybe (Handler CompletionRequest))
- completionResolveHandler :: !(Maybe (Handler CompletionItemResolveRequest))
- signatureHelpHandler :: !(Maybe (Handler SignatureHelpRequest))
- definitionHandler :: !(Maybe (Handler DefinitionRequest))
- referencesHandler :: !(Maybe (Handler ReferencesRequest))
- documentHighlightHandler :: !(Maybe (Handler DocumentHighlightRequest))
- documentSymbolHandler :: !(Maybe (Handler DocumentSymbolRequest))
- workspaceSymbolHandler :: !(Maybe (Handler WorkspaceSymbolRequest))
- codeActionHandler :: !(Maybe (Handler CodeActionRequest))
- codeLensHandler :: !(Maybe (Handler CodeLensRequest))
- codeLensResolveHandler :: !(Maybe (Handler CodeLensResolveRequest))
- documentFormattingHandler :: !(Maybe (Handler DocumentFormattingRequest))
- documentRangeFormattingHandler :: !(Maybe (Handler DocumentRangeFormattingRequest))
- documentTypeFormattingHandler :: !(Maybe (Handler DocumentOnTypeFormattingRequest))
- renameHandler :: !(Maybe (Handler RenameRequest))
- documentLinkHandler :: !(Maybe (Handler DocumentLinkRequest))
- documentLinkResolveHandler :: !(Maybe (Handler DocumentLinkResolveRequest))
- executeCommandHandler :: !(Maybe (Handler ExecuteCommandRequest))
- willSaveWaitUntilTextDocHandler :: !(Maybe (Handler WillSaveWaitUntilTextDocumentResponse))
- didChangeConfigurationParamsHandler :: !(Maybe (Handler DidChangeConfigurationNotification))
- didOpenTextDocumentNotificationHandler :: !(Maybe (Handler DidOpenTextDocumentNotification))
- didChangeTextDocumentNotificationHandler :: !(Maybe (Handler DidChangeTextDocumentNotification))
- didCloseTextDocumentNotificationHandler :: !(Maybe (Handler DidCloseTextDocumentNotification))
- didSaveTextDocumentNotificationHandler :: !(Maybe (Handler DidSaveTextDocumentNotification))
- didChangeWatchedFilesNotificationHandler :: !(Maybe (Handler DidChangeWatchedFilesNotification))
- initializedHandler :: !(Maybe (Handler InitializedNotification))
- willSaveTextDocumentNotificationHandler :: !(Maybe (Handler WillSaveTextDocumentNotification))
- cancelNotificationHandler :: !(Maybe (Handler CancelNotification))
- responseHandler :: !(Maybe (Handler BareResponseMessage))
- data Options = Options {
- textDocumentSync :: Maybe TextDocumentSyncOptions
- completionProvider :: Maybe CompletionOptions
- signatureHelpProvider :: Maybe SignatureHelpOptions
- codeLensProvider :: Maybe CodeLensOptions
- documentOnTypeFormattingProvider :: Maybe DocumentOnTypeFormattingOptions
- documentLinkProvider :: Maybe DocumentLinkOptions
- executeCommandProvider :: Maybe ExecuteCommandOptions
- data OutMessage
- = ReqHover HoverRequest
- | ReqCompletion CompletionRequest
- | ReqCompletionItemResolve CompletionItemResolveRequest
- | ReqSignatureHelp SignatureHelpRequest
- | ReqDefinition DefinitionRequest
- | ReqFindReferences ReferencesRequest
- | ReqDocumentHighlights DocumentHighlightRequest
- | ReqDocumentSymbols DocumentSymbolRequest
- | ReqWorkspaceSymbols WorkspaceSymbolRequest
- | ReqCodeAction CodeActionRequest
- | ReqCodeLens CodeLensRequest
- | ReqCodeLensResolve CodeLensResolveRequest
- | ReqDocumentFormatting DocumentFormattingRequest
- | ReqDocumentRangeFormatting DocumentRangeFormattingRequest
- | ReqDocumentOnTypeFormatting DocumentOnTypeFormattingRequest
- | ReqRename RenameRequest
- | ReqExecuteCommand ExecuteCommandRequest
- | RspHover HoverResponse
- | RspCompletion CompletionResponse
- | RspCompletionItemResolve CompletionItemResolveResponse
- | RspSignatureHelp SignatureHelpResponse
- | RspDefinition DefinitionResponse
- | RspFindReferences ReferencesResponse
- | RspDocumentHighlights DocumentHighlightsResponse
- | RspDocumentSymbols DocumentSymbolsResponse
- | RspWorkspaceSymbols WorkspaceSymbolsResponse
- | RspCodeAction CodeActionResponse
- | RspCodeLens CodeLensResponse
- | RspCodeLensResolve CodeLensResolveResponse
- | RspDocumentFormatting DocumentFormattingResponse
- | RspDocumentRangeFormatting DocumentRangeFormattingResponse
- | RspDocumentOnTypeFormatting DocumentOnTypeFormattingResponse
- | RspRename RenameResponse
- | RspExecuteCommand ExecuteCommandResponse
- | NotInitialized InitializedNotification
- | NotDidChangeConfigurationParams DidChangeConfigurationNotification
- | NotDidOpenTextDocument DidOpenTextDocumentNotification
- | NotDidChangeTextDocument DidChangeTextDocumentNotification
- | NotDidCloseTextDocument DidCloseTextDocumentNotification
- | NotWillSaveTextDocument WillSaveTextDocumentNotification
- | NotDidSaveTextDocument DidSaveTextDocumentNotification
- | NotDidChangeWatchedFiles DidChangeWatchedFilesNotification
- | NotCancelRequest CancelNotification
- | RspFromClient BareResponseMessage
- defaultLanguageContextData :: Handlers -> Options -> LspFuncs c -> TVar Int -> SendFunc -> LanguageContextData c
- initializeRequestHandler :: Show c => InitializeCallback c -> TVar (LanguageContextData c) -> InitializeRequest -> IO ()
- makeResponseMessage :: RequestMessage ClientMethod req resp -> resp -> ResponseMessage resp
- makeResponseError :: LspIdRsp -> ResponseError -> ResponseMessage ()
- setupLogger :: Maybe FilePath -> [String] -> Priority -> IO ()
- sendErrorResponseS :: SendFunc -> LspIdRsp -> ErrorCode -> Text -> IO ()
- sendErrorLogS :: SendFunc -> Text -> IO ()
- sendErrorShowS :: SendFunc -> Text -> IO ()
- reverseSortEdit :: WorkspaceEdit -> WorkspaceEdit
Documentation
handleRequest :: Show c => InitializeCallback c -> TVar (LanguageContextData c) -> ByteString -> ByteString -> IO () Source #
data LanguageContextData a Source #
state used by the LSP dispatcher to manage the message loop
LanguageContextData | |
|
type Handler b = b -> IO () Source #
The Handler type captures a function that receives local read-only state
a
, a function to send a reply message once encoded as a ByteString, and a
received message of type b
type InitializeCallback c = (DidChangeConfigurationNotification -> Either Text c, LspFuncs c -> IO (Maybe ResponseError)) Source #
The function in the LSP process that is called once the initialize
message is received. Message processing will only continue once this returns,
so it should create whatever processes are needed.
Returned to the server on startup, providing ways to interact with the client.
LspFuncs | |
|
Callbacks from the language server to the language handler
Language Server Protocol options supported by the given language server. These are automatically turned into capabilities reported to the client during initialization.
data OutMessage Source #
Wrap all the protocol messages into a single type, for use in the language handler in storing the original message
defaultLanguageContextData :: Handlers -> Options -> LspFuncs c -> TVar Int -> SendFunc -> LanguageContextData c Source #
initializeRequestHandler :: Show c => InitializeCallback c -> TVar (LanguageContextData c) -> InitializeRequest -> IO () Source #
===============================================================
Handlers
makeResponseMessage :: RequestMessage ClientMethod req resp -> resp -> ResponseMessage resp Source #
makeResponseError :: LspIdRsp -> ResponseError -> ResponseMessage () Source #
setupLogger :: Maybe FilePath -> [String] -> Priority -> IO () Source #
===============================================================
utility
Logger
reverseSortEdit :: WorkspaceEdit -> WorkspaceEdit Source #
The changes in a workspace edit should be applied from the end of the file toward the start. Sort them into this order.