Language Server Protocol¶
This blog briefs the LSP(language server protocol) specification.
Brief Notes of LSP¶
LSP is the acronym of Language Server Protocol
defined by Microsoft for Vscode. This series introduce the [email protected] as haskell implementation roots on it.
LSP base protocol is an http request like protocol. Its base protocol contains header and content. RPC-JSON
is used as the format of content. A rpc-json
pre-defines four fields(jsonrpc
, id
, method
,param
) at the root level. Extended fields at root level is not correct extension. Hence, a typical request look like the snippet below.
{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file:///path/to/your/code/file.js"
},
"position": {
"line": 8,
"character": 15
}
}
}
There are many json structures to communicate between server and client. Then there many language features with different method names, for example, textDocument/completion
, textDocument/definition
and so forth.
Specification is cramped with every stripe of details, hence, a brief skim reading to get the ideas are enough. In the other words, it should be the encyclopedia to look up when trying to implement a language feature, but not learn it carefully before really coding.