I saw recently that Nova fixed a bug with LanguageClient to allow extensions to implement custom LSP requests. I can now see that my code inside of the handler for onRequest
is being called but it seems that what I return does not get sent in the request’s response.
My code
I can see my debug statements being called in the extension console, but it seems to always pass null
back in the response?
client.onRequest("custom/schema/request", ([uri]: [string]) => {
debug("custom/schema/request", uri);
const editor = nova.workspace.textEditors.find(
(e) => e.document.uri === uri
);
if (!editor) return [];
const text = editor.document.getTextInRange(
new Range(0, editor.document.length)
);
const apiVersion = /^apiVersion: +(\S+)$/m.exec(text);
const kind = /^kind: +(\S+)$/m.exec(text);
if (!apiVersion || !kind) return [];
debug("custom/schema/request", [apiVersion[1], kind[1]]);
return [{ uri: "kubernetes", name: kind[1], description: apiVersion[1] }];
});
client.start();
client.sendNotification("yaml/registerCustomSchemaRequest");
The request
{"jsonrpc":"2.0","id":1,"method":"custom/schema/request","params":["file:///Users/rob/dev/nova/yaml/examples/ingress.yml"]}
The response
{"jsonrpc":"2.0","method":"yaml\/registerCustomSchemaRequest","params":null}Content-Length: 38
{"jsonrpc":"2.0","id":2,"result":null}
Also, should the ids match up?