tliron / glsp

Language Server Protocol SDK for Go
Apache License 2.0
169 stars 23 forks source link

Difference between `context.Notify` and `context.Call` #35

Open Myzel394 opened 1 week ago

Myzel394 commented 1 week ago

Hey I was wondering what's the difference between context.Notify and context.Call - it took me a few hours to find out that you need to use context.Call for the workspace/applyEdit command to work :C I think some documentation here could potentially save future people's time too :D

From the arguments, I can see that context.Call takes a result argument - what is this exactly? From my understanding, I'd expect this to be returned from the client instead of the server specifying it

rcjsuen commented 1 week ago

From the arguments, I can see that context.Call takes a result argument - what is this exactly? From my understanding, I'd expect this to be returned from the client instead of the server specifying it

When you send a JSON-RPC request, you are expecting a result to come back from the "other side".

// request
{"jsonrpc": "2.0", "id": 1, "method": "subtract", "params": [42, 23]}
// result
{"jsonrpc": "2.0", "id": 1, "result": 19}

The result argument you specify will have the result deserialized "into" as can be seen here.