Skip to content

Commit

Permalink
Responding to events
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jan 21, 2024
1 parent d9eab54 commit f8fdeae
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ let server = MyRestartingServer(configuration: config)

An `AsyncSequence` that uses FS events and glob patterns to handle `DidChangeWatchedFiles`. It is available only for macOS.


### Responding to Events

You can respond to server events using `eventSequence`. Be careful here as some servers require responses to certain requests. It is also potentially possible that not all request types have been mapped in the ServerRequest type from [LanguageServerProtocol][languageserverprotocol].

```swift
Task {
for await event in server.eventSequence {
print("receieved event:", event)

switch event {
case let .request(id: id, request: request):
request.relyWithError(MyError.unsupported)
default:
print("dropping notification/error")
}
}
}
```
## Suggestions or Feedback

We'd love to hear from you! Get in touch via an issue or pull request.
Expand Down

0 comments on commit f8fdeae

Please sign in to comment.