LSP


haskell-language-server使


https://github.com/tennashi/lsp_spec_ja
\r\n

Content-Length: <>
Content-Type: <mine type> application/vscode-jsonrpc; charset=utf-8
ascii

JSON-RPC使
Content-Length: ...\r\n
\r\n
{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/didOpen",
"params": {
...
}
}

jsonrpc LSP "2.0"
interface Message {
jsonrpc: string;
}

interface RequestMessage extends Message {
/**
* ID
*/
id: number | string;
/**
*
*/
method: string;
/**
*
*/
params?: array | object;
}

JSON RPC result null
interface ResponseMessage extends Message {
/**
* ID
*/
id: number | string | null;
/**
*
*
*/
result?: string | number | boolean | object | null;
/**
*
*/
error?: ResponseError;
}
interface ResponseError {
/**
*
*/
code: number;
/**
*
*/
message: string;
/**
*
*
*/
data?: string | number | boolean | array | object | null;
}
export namespace ErrorCodes {
// JSON RPC
export const ParseError: number = -32700;
export const InvalidRequest: number = -32600;
export const MethodNotFound: number = -32601;
export const InvalidParams: number = -32602;
export const InternalError: number = -32603;
export const serverErrorStart: number = -32099;
export const serverErrorEnd: number = -32000;
export const ServerNotInitialized: number = -32002;
export const UnknownErrorCode: number = -32001;
//
export const RequestCancelled: number = -32800;
export const ContentModified: number = -32801;
}

Notification
interface NotificationMessage extends Message {
/**
*
*/
method: string;
/**
*
*/
params?: array | object;
}

$/ MethodNotFound

UTF-16 a𐐀b a 0 𐐀 1 b 3


Initialize Request
initialize
params InitializeParams
interface InitializeParams {
/**
* ID
* null
*
* (`exit` )
*/
processId: number | null;
/**
*
*
* @since 3.15.0
*/
clientInfo?: {
/**
*
*/
name: string;
/**
*
*/
version?: string;
};
/**
* `rootPath` null
*
* @deprecated rootUri
*/
rootPath?: string | null;
/**
* `rootUri` null
* `rootPath` `rootUri` `rootUri`
*/
rootUri: DocumentUri | null;
/**
*
*/
initializationOptions?: any;
/**
* ()
*/
capabilities: ClientCapabilities;
/**
* ('off')
*/
trace?: 'off' | 'messages' | 'verbose';
/**
*
*
*
*
* `null`
*
* 3.6.0
*/
workspaceFolders?: WorkspaceFolder[] | null;
}

interface InitializeResult {
/**
*
*/
capabilities: ServerCapabilities;
/**
*
*
* @since 3.15.0
*/
serverInfo?: {
/**
*
*/
name: string;
/**
*
*/
version?: string;
};
}

Initialized notification
initialize initialized
initialized
params: {}