@gluonjs/language-server / packages/language-server/src / JsonRpcRequest
Interface: JsonRpcRequest
Properties
id?
readonlyoptionalid?:string|number
jsonrpc
readonlyjsonrpc:"2.0"
method
readonlymethod:string
params?
readonlyoptionalparams?:any
Example
Send an LSP method, optional ID, and parameters through the protocol server using the JSON-RPC 2.0 envelope:
import { GluonProtocolServer, type JsonRpcRequest, type JsonRpcResponse } from '@gluonjs/language-server';
const server = new GluonProtocolServer();
const initialize = { jsonrpc: '2.0', id: 1, method: 'initialize', params: {} } satisfies JsonRpcRequest;
const responses: readonly JsonRpcResponse[] = server.handle(initialize);
const open = {
jsonrpc: '2.0',
method: 'textDocument/didOpen',
params: { textDocument: { uri: 'file:///src/app.ts', text: `import { html } from '@gluonjs/core'; const view = html\`<img>text</img>\`;` } },
} satisfies JsonRpcRequest;
const notifications = server.handle(open);
console.log(responses[0]?.result, notifications[0]?.method, notifications[0]?.params);