VSCode Language Client extension - how does client receive message from the server (in 2024)?

36 views Asked by At

I want to write a VSCode extension that receives response from the LSP server. From the client to the server was easy. You only need to call client.sendRequest. It's also easy to use built-in methods. The backend will help you handle everything. However, it seems hard to send a custom method response from the server to the client. After some Googling, this 5-year-old SO question seems to be what I need. However, the code in the link doesn't work anymore. I can't even find the method client.onReady(). How do I receive response in the 2024 way?

1

There are 1 answers

0
盛安安 On

I found out the answer. You just need to do

let response = await client.sendRequest()

The type of response is likely unknown, so you have to cast it yourself.