Comments (6)
@felixfbecker: you can now find a more detailed doc here https://github.com/Microsoft/vscode-languageserver-protocol. It is documented in a request / response form like REST APIs are documented. Let me know if this helps. One thing I would like to add there as well is some sequence diagrams for typically request / response flows.
from vscode-languageserver-node.
@felixfbecker working on a documentation in mark down.
What also helps a lot is the following file: https://github.com/Microsoft/vscode-languageserver-node/blob/master/server/src/protocol.ts
It is basically the protocol in terms of TS interfaces.
from vscode-languageserver-node.
@felixfbecker let me know if you need any short term support. I am happy to answers questions.
from vscode-languageserver-node.
@felixfbecker: besides the server protocol you need to know the base json-rpc protocol. The definition looks like this:
Base Protocol
The base protocol consists of a header and a content part (comparable to http). The header and content part are separated by a '\r\n'.
Header Part
The header part consist of header fields. Header fields are separated from each other by '\r\n'. The last header field needs to be terminated with '\r\n' as well. Currently the following header fields are supported:
Header File Name | Value Type | Description |
---|---|---|
Content-Length | number | The length of the content part |
Content-Type | string | The mime typ of the content part. Defaults to application/vscode-jsonrpc; charset=utf8 |
The header part is encoded using the 'ascii' encoding. This includes the '\r\n' separating the header and content part.
Content Part
Contains the actual content of the message. The content part of a message uses JSON-RPC to describe requests, responses and notifications. The content part is encoded using the charset provided in the Content-Type field. It defaults to 'utf8' which is the only currently supported encoding.
Example:
Content-Length: ...\r\n
\r\n
{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/didOpen",
"params": {
...
}
}
Base Protocol JSON structures
The following TypeScript definitions describe the JSON-RPC protocol as implemented by VSCode:
Abstract Message
A general message as defined by JSON-RPC. The language server protocol always uses "2.0" as the jsonrpc version.
interface Message {
jsonrpc: string;
}
RequestMessage
A request message to decribe a request between the client and the server. Every processed request must send a response back to the sender of the request.
interface RequestMessage extends Message {
/**
* The request id.
*/
id: number | string;
/**
* The method to be invoked.
*/
method: string;
/**
* The method's params.
*/
params?: any
}
Response Message
Response Message send as a result of a request.
interface ResponseMessage extends Message {
/**
* The request id.
*/
id: number | string;
/**
* The result of a request. This can be omitted in
* the case of an error.
*/
result?: any;
/**
* The error object in case a request fails.
*/
error?: ResponseError<any>;
}
interface ResponseError<D> {
/**
* A number indicating the error type that occured.
*/
code: number;
/**
* A string providing a short decription of the error.
*/
message: string;
/**
* A Primitive or Structured value that contains additional
* information about the error. Can be omitted.
*/
data?: D;
}
export namespace ErrorCodes {
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;
}
Notification Message
A notification message. A processed notification message must not send a response back. They work like events.
interface NotificationMessage extends Message {
/**
* The method to be invoked.
*/
method: string;
/**
* The notification's params.
*/
params?: any
}
The corresponding TS file defining it is here: https://github.com/Microsoft/vscode-languageserver-node/blob/master/jsonrpc/src/messages.ts
Hope that gets you started.
from vscode-languageserver-node.
@dbaeumer Thank you for your detailed description of the protocol. Maybe you can give me an example how would a typical sequence look like for a language server, for example for IntelliSense, or getting notified when a file changed? And what exactly is "the method to be invoked"?
from vscode-languageserver-node.
Closing this since the documentation is tracked in https://github.com/Microsoft/vscode-languageserver-protocol
from vscode-languageserver-node.
Related Issues (20)
- Add `fifo` as a transport option HOT 7
- [Extension Host] TypeError: Cannot read properties of undefined (reading 'stdio') HOT 3
- No clear way to write no-op middleware for responses to client-initiated requests HOT 1
- [vscode-languageclient]: Send extra \r\n at the end HOT 4
- Webpack warning HOT 10
- `Connection::sendRequest` never fullfills HOT 3
- `codeAction.resolveSupport` does not have `command` field to detect support, but it supports it
- No clear way to make a response handler for any response such as "textDocument/codeAction" HOT 8
- Question: Minimum requirements for LSP server to support semantic highlighting HOT 2
- Rename is not called if server returns { defaultBehavior: true } in prepareRename HOT 2
- Conform to the recommendation in the standard for the socket argument, which is currently `--socket` instead of `--port` HOT 1
- Inspect message from the server HOT 1
- Consider Adding a `ExtensionVersion` to `ClientInfo` HOT 1
- `"<server-id>.trace.server": "verbose"` does not log content of messages HOT 4
- LS Client does not send `workDoneProgress` token for formatting HOT 2
- `InlineCompletionContext.SelectedCompletionInfo.range` is a JavaScript Array at runtime (type mismatch) HOT 2
- metaModel has mismatched backticks/quotes HOT 3
- onDefinition handler is not called when onHover handler is HOT 5
- Incorrect type "TraceValues" in MetaModel.json HOT 2
- Server side trace HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-languageserver-node.