I took a step back with my LSP and decided that what I really need is a template based system for building responses.
Previously I had started creating the JSON on the fly but realised that the jsonrpc specification has what it called interfaces which are basically templates, so I wrote a Type that allows you to add templates and variables and then it joins them all together for you. It works well but I might find a better way at some later time.
After getting the template system working and removing some debug messages that I think might be inadvertently picked up as responses.
For reference, the LSP receives an "initialise" message from the client that contains a lot of data. In my case it was over 4k in size. The LSP then returns an
"initialized" message and receives confirmation from the client in the form of an "initialized" notification.
The "initialize" and "initialized" messages are very similar. Both contain "jsonrpc" and "method" fields, but only the "initialize" message contains an "id" field. The "id" field must be returned in a reply and therefore any message that doesn't contain one is a notification that does not expect a reply.
My LSP code takes the "method" field and uses it to create an object using reflection and populating it with data from JSON. So far I have "msg_initialize" and "msg_initialized" Types that are working and a "msg_shutdown" that doesn't seem to work at the moment.
My LSP "initialize" response currently only returns the hover capability which means I should start getting additional messages when I get back to it.
Comments
Post a Comment