Skip to content

Commit f5a53e0

Browse files
Details on responding to events
1 parent 3643e04 commit f5a53e0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,28 @@ Right now, there are still some bits useful for client support in this library:
4747

4848
The intention is to migrate all of these out into LanguageClient, leaving this library purely focused on protocol-level support.
4949

50+
## Usage
51+
52+
### Responding to Events
53+
54+
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. The spec is big! If you find a problem, please open an issue!
55+
56+
```swift
57+
Task {
58+
for await event in server.eventSequence {
59+
print("receieved event:", event)
60+
61+
switch event {
62+
case let .request(id: id, request: request):
63+
request.relyWithError(MyError.unsupported)
64+
default:
65+
print("dropping notification/error")
66+
}
67+
}
68+
}
69+
```
70+
71+
5072
## Supported Features
5173

5274
The LSP [specification](https://microsoft.github.io/language-server-protocol/specification) is large, and this library currently does not implement it all. The intention is to support the 3.x specification, but be as backwards-compatible as possible with pre-3.0 servers.

0 commit comments

Comments
 (0)