This document describes version 3.0 of the language server protocol. Major goals of the 3.0 version are:
- add support for client feature flags to support that servers can adapt to different client capabilities. An example is the new
textDocument/willSaveWaitUntil
request which not all clients might be able to support. If the feature is disabled in the client capabilities sent on the initialize request, the server can't rely on receiving the request. - add support to experiment with new features. The new
ClientCapabilities.experimental
section together with feature flags allow servers to provide experimental feature without the need of ALL clients to adopt them immediatelly. - servers can more dynamically react to client features. Capabilities can now be registered and unregistered after the initialize request using the new
client/registerCapability
andclient/unregisterCapability
. This for example allows servers to react to settings or configuration changes without a restart. - add support for
textDocument/willSave
notification andtextDocument/willSaveWaitUntil
request. - add support for
textDocument/documentLink
request. - add a
rootUri
property to the initializeParams in favour of therootPath
property.
An implementation for node of the 3.0 version of the protocol can be found here.
The 2.x version of this document can be found here. The 1.x version of this document can be found here.
- Added optional
commitCharacters
property to theCompletionItem
- Make the
WorkspaceEdit
changes backwards compatible. - Updated the specification to correctly describe the breaking changes from 2.x to 3.x around
WorkspaceEdit
andTextDocumentEdit
.
General
- ↩️ initialize
- New ➡️ initialized
- ↩️ shutdown
- ➡️ exit
- ➡️ ⬅️ $/cancelRequest
Window
New Client
Workspace
- ➡️ workspace/didChangeConfiguration
- ➡️ workspace/didChangeWatchedFiles
- ↩️ workspace/symbol
- New ↩️ workspace/executeCommand
- New ↪️ workspace/applyEdit
Document
- ⬅️ textDocument/publishDiagnostics
- ➡️ textDocument/didOpen
- ➡️ textDocument/didChange
- ➡️ textDocument/willSave
- New ↩️ textDocument/willSaveWaitUntil
- New ➡️ textDocument/didSave
- ➡️ textDocument/didClose
- ↩️ textDocument/completion
- ↩️ completionItem/resolve
- ↩️ textDocument/hover
- ↩️ textDocument/signatureHelp
- ↩️ textDocument/references
- ↩️ textDocument/documentHighlight
- ↩️ textDocument/documentSymbol
- ↩️ textDocument/formatting
- ↩️ textDocument/rangeFormatting
- ↩️ textDocument/onTypeFormatting
- ↩️ textDocument/definition
- ↩️ textDocument/codeAction
- ↩️ textDocument/codeLens
- ↩️ codeLens/resolve
- ↩️ textDocument/documentLink
- ↩️ documentLink/resolve
- ↩️ textDocument/rename
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'.
The header part consists of header fields. Each header field is comprised of a name and a value, separated by ': ' (a colon and a space). Each header field is terminated by '\r\n'. Considering the last header field and the overall header itself are each terminated with '\r\n', and that at least one header is mandatory, this means that two '\r\n' sequences always immediately precede the content part of a message.
Currently the following header fields are supported:
Header Field Name | Value Type | Description |
---|---|---|
Content-Length | number | The length of the content part in bytes. This header is required. |
Content-Type | string | The mime type of the content part. Defaults to application/vscode-jsonrpc; charset=utf-8 |
The header part is encoded using the 'ascii' encoding. This includes the '\r\n' separating the header and 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 utf-8
, which is the only encoding supported right now.
Changed Prior version of the protocol used the string constant
utf8
which is not a correct encoding constant according to specification). For backwards compatibility it is highly recommended that a client and a server treats the stringutf8
asutf-8
.
Content-Length: ...\r\n
\r\n
{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/didOpen",
"params": {
...
}
}
The following TypeScript definitions describe the base JSON-RPC protocol:
A general message as defined by JSON-RPC. The language server protocol always uses "2.0" as the jsonrpc version.
interface Message {
jsonrpc: string;
}
A request message to describe 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 sent as a result of a request. If a request doesn't provide a result value the receiver of a request still needs to return a response message to conform to the JSON RPC specification. The result property of the ResponseMessage should be set to null
in this case to signal a successful request.
interface ResponseMessage extends Message {
/**
* The request id.
*/
id: number | string | null;
/**
* 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 occurred.
*/
code: number;
/**
* A string providing a short description 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 {
// Defined by 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;
// Defined by the protocol.
export const RequestCancelled: number = -32800;
}
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
}
Notification and requests ids starting with '$/' are messages which are protocol implementation dependent and might not be implementable in all clients or servers. For example if the server implementation uses a single threaded synchronous programming language then there is little a server can do to react to a '$/cancelRequest'. If a server or client receives notifications or requests starting with '$/' it is free to ignore them if they are unknown.
The base protocol offers support for request cancellation. To cancel a request, a notification message with the following properties is sent:
Notification:
- method: '$/cancelRequest'
- params:
CancelParams
defined as follows:
interface CancelParams {
/**
* The request id to cancel.
*/
id: number | string;
}
A request that got canceled still needs to return from the server and send a response back. It can not be left open / hanging. This is in line with the JSON RPC protocol that requires that every request sends a response back. In addition it allows for returning partial results on cancel. If the requests returns an error response on cancellation it is advised to set the error code to ErrorCodes.RequestCancelled
.
The language server protocol defines a set of JSON-RPC request, response and notification messages which are exchanged using the above base protocol. This section starts describing the basic JSON structures used in the protocol. The document uses TypeScript interfaces to describe these. Based on the basic JSON structures, the actual requests with their responses and the notifications are described.
The protocol currently assumes that one server serves one tool. There is currently no support in the protocol to share one server between different tools. Such a sharing would require additional protocol to either lock a document to support concurrent editing.
URI's are transferred as strings. The URI's format is defined in http://tools.ietf.org/html/rfc3986
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ \ / \
urn:example:animal:ferret:nose
We also maintain a node module to parse a string into scheme
, authority
, path
, query
, and fragment
URI components. The GitHub repository is https://github.com/Microsoft/vscode-uri the npm module is https://www.npmjs.com/package/vscode-uri.
Many of the interfaces contain fields that correspond to the URI of a document. For clarity, the type of such a field is declared as a DocumentUri
. Over the wire, it will still be transferred as a string, but this guarantees that the contents of that string can be parsed as a valid URI.
type DocumentUri = string;
The current protocol is tailored for textual documents whose content can be represented as a string. There is currently no support for binary documents. A position inside a document (see Position definition below) is expressed as a zero-based line and character offset. The offsets are based on a UTF-16 string representation. So a string of the form a𐐀b
the character offset of the character a
is 0, the character offset of 𐐀
is 1 and the character offset of b is 3 since 𐐀
is represented using two code units in UTF-16. To ensure that both client and server split the string into the same line representation the protocol specifies the following end-of-line sequences: '\n', '\r\n' and '\r'.
export const EOL: string[] = ['\n', '\r\n', '\r'];
Position in a text document expressed as zero-based line and zero-based character offset. A position is between two characters like an 'insert' cursor in a editor.
interface Position {
/**
* Line position in a document (zero-based).
*/
line: number;
/**
* Character offset on a line in a document (zero-based).
*/
character: number;
}
A range in a text document expressed as (zero-based) start and end positions. A range is comparable to a selection in an editor. Therefore the end position is exclusive.
interface Range {
/**
* The range's start position.
*/
start: Position;
/**
* The range's end position.
*/
end: Position;
}
Represents a location inside a resource, such as a line inside a text file.
interface Location {
uri: DocumentUri;
range: Range;
}
Represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource.
interface Diagnostic {
/**
* The range at which the message applies.
*/
range: Range;
/**
* The diagnostic's severity. Can be omitted. If omitted it is up to the
* client to interpret diagnostics as error, warning, info or hint.
*/
severity?: number;
/**
* The diagnostic's code. Can be omitted.
*/
code?: number | string;
/**
* A human-readable string describing the source of this
* diagnostic, e.g. 'typescript' or 'super lint'.
*/
source?: string;
/**
* The diagnostic's message.
*/
message: string;
}
The protocol currently supports the following diagnostic severities:
namespace DiagnosticSeverity {
/**
* Reports an error.
*/
export const Error = 1;
/**
* Reports a warning.
*/
export const Warning = 2;
/**
* Reports an information.
*/
export const Information = 3;
/**
* Reports a hint.
*/
export const Hint = 4;
}
Represents a reference to a command. Provides a title which will be used to represent a command in the UI. Commands are identified by a string identifier. The protocol currently doesn't specify a set of well-known commands. So executing a command requires some tool extension code.
interface Command {
/**
* Title of the command, like `save`.
*/
title: string;
/**
* The identifier of the actual command handler.
*/
command: string;
/**
* Arguments that the command handler should be
* invoked with.
*/
arguments?: any[];
}
A textual edit applicable to a text document.
interface TextEdit {
/**
* The range of the text document to be manipulated. To insert
* text into a document create a range where start === end.
*/
range: Range;
/**
* The string to be inserted. For delete operations use an
* empty string.
*/
newText: string;
}
If multiple TextEdit
s are applied to a text document, all text edits describe changes made to the initial document version. Execution-wise text edits should be applied from the bottom to the top of the text document. Overlapping text edits are not supported.
Describes textual changes on a single text document. The text document is referred to as a VersionedTextDocumentIdentifier
to allow clients to check the text document version before an edit is applied. A TextDocumentEdit
describes all changes on a version Si and after they are applied move the document to version Si+1. So the creator of a TextDocumentEdit
doesn't need to sort the array or do any kind of ordering. However the edits must be non overlapping.
export interface TextDocumentEdit {
/**
* The text document to change.
*/
textDocument: VersionedTextDocumentIdentifier;
/**
* The edits to be applied.
*/
edits: TextEdit[];
}
Changed A workspace edit represents changes to many resources managed in the workspace. The edit should either provide
changes
ordocumentChanges
. If the client can handle versioned document edits and ifdocumentChange
s are present, the latter are preferred overchanges
.
export interface WorkspaceEdit {
/**
* Holds changes to existing resources.
*/
changes?: { [uri: string]: TextEdit[]; };
/**
* An array of `TextDocumentEdit`s to express changes to n different text documents
* where each text document edit addresses a specific version of a text document.
* Whether a client supports versioned document edits is expressed via
* `WorkspaceClientCapabilities.workspaceEdit.documentChanges`.
*/
documentChanges?: TextDocumentEdit[];
}
Text documents are identified using a URI. On the protocol level, URIs are passed as strings. The corresponding JSON structure looks like this:
interface TextDocumentIdentifier {
/**
* The text document's URI.
*/
uri: DocumentUri;
}
An item to transfer a text document from the client to the server.
interface TextDocumentItem {
/**
* The text document's URI.
*/
uri: DocumentUri;
/**
* The text document's language identifier.
*/
languageId: string;
/**
* The version number of this document (it will increase after each
* change, including undo/redo).
*/
version: number;
/**
* The content of the opened text document.
*/
text: string;
}
An identifier to denote a specific version of a text document.
interface VersionedTextDocumentIdentifier extends TextDocumentIdentifier {
/**
* The version number of this document.
*/
version: number;
}
Was TextDocumentPosition
in 1.0 with inlined parameters.
A parameter literal used in requests to pass a text document and a position inside that document.
interface TextDocumentPositionParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
/**
* The position inside the text document.
*/
position: Position;
}
A document filter denotes a document through properties like language
, schema
or pattern
. An example is a filter that applies to TypeScript files on disk. Another example is a filter the applies to JSON files with name package.json
:
{ language: 'typescript', scheme: 'file' }
{ language: 'json', pattern: '**/package.json' }
export interface DocumentFilter {
/**
* A language id, like `typescript`.
*/
language?: string;
/**
* A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
*/
scheme?: string;
/**
* A glob pattern, like `*.{ts,js}`.
*/
pattern?: string;
}
A document selector is the combination of one or more document filters.
export type DocumentSelector = DocumentFilter[];
This section documents the actual language server protocol. It uses the following format:
- a header describing the request
- a Request: section describing the format of the request sent. The method is a string identifying the request the params are documented using a TypeScript interface
- a Response: section describing the format of the response. The result item describes the returned data in case of a success. The error.data describes the returned data in case of an error. Please remember that in case of a failure the response already contains an error.code and an error.message field. These fields are only speced if the protocol forces the use of certain error codes or messages. In cases where the server can decide on these values freely they aren't listed here.
- a Registration Options section decribing the registration option if the request or notification supports dynamic capability registration.
Responses for requests should be sent in the same order as the requests appear on the server or client side. So for example if a server receives a textDocument/completion
request and then a textDocument/signatureHelp
request it should first return the response for the textDocument/completion
and then the response for textDocument/signatureHelp
.
How the server internally processes the requests is up to the server implementation. If the server decides to execute them in parallel and this produces correct result the server is free to do so. The server is also allowed to reorder requests and notification if the reordering doesn't affect correctness.
The current protocol specification defines that the lifetime of a server is managed by the client (e.g. a tool like VS Code or Emacs). It is up to the client to decide when to start (process vise) and when to shutdown a server.
The initialize request is sent as the first request from the client to the server. If the server receives request or notification before the initialize
request it should act as follows:
- for a request the respond should be errored with
code: -32002
. The message can be picked by the server. - notifications should be dropped, except for the exit notification. This will allow the exit a server without an initialize request.
Until the server has responded to the initialize
request with an InitializeResult
the client must not sent any additional requests or notifications to the server.
Updated: During the
initialize
request the server is allowed to sent the notificationswindow/showMessage
,window/logMessage
andtelemetry/event
as well as thewindow/showMessageRequest
request to the client.
Request:
- method: 'initialize'
- params:
InitializeParams
defined as follows:
interface InitializeParams {
/**
* The process Id of the parent process that started
* the server. Is null if the process has not been started by another process.
* If the parent process is not alive then the server should exit (see exit notification) its process.
*/
processId: number | null;
/**
* The rootPath of the workspace. Is null
* if no folder is open.
*
* @deprecated in favour of rootUri.
*/
rootPath?: string | null;
/**
* The rootUri of the workspace. Is null if no
* folder is open. If both `rootPath` and `rootUri` are set
* `rootUri` wins.
*/
rootUri: DocumentUri | null;
/**
* User provided initialization options.
*/
initializationOptions?: any;
/**
* The capabilities provided by the client (editor or tool)
*/
capabilities: ClientCapabilities;
/**
* The initial trace setting. If omitted trace is disabled ('off').
*/
trace?: 'off' | 'messages' | 'verbose';
}
Where ClientCapabilities
, TextDocumentClientCapabilities
and WorkspaceClientCapabilities
are defined as follows:
New:
WorkspaceClientCapabilities
define capabilities the editor / tool provides on the workspace:
/**
* Workspace specific client capabilities.
*/
export interface WorkspaceClientCapabilities {
/**
* The client supports applying batch edits to the workspace by supporting
* the request 'workspace/applyEdit'
*/
applyEdit?: boolean;
/**
* Capabilities specific to `WorkspaceEdit`s
*/
workspaceEdit?: {
/**
* The client supports versioned document changes in `WorkspaceEdit`s
*/
documentChanges?: boolean;
};
/**
* Capabilities specific to the `workspace/didChangeConfiguration` notification.
*/
didChangeConfiguration?: {
/**
* Did change configuration notification supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `workspace/didChangeWatchedFiles` notification.
*/
didChangeWatchedFiles?: {
/**
* Did change watched files notification supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `workspace/symbol` request.
*/
symbol?: {
/**
* Symbol request supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `workspace/executeCommand` request.
*/
executeCommand?: {
/**
* Execute command supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
}
New:
TextDocumentClientCapabilities
define capabilities the editor / tool provides on text documents.
/**
* Text document specific client capabilities.
*/
export interface TextDocumentClientCapabilities {
synchronization?: {
/**
* Whether text document synchronization supports dynamic registration.
*/
dynamicRegistration?: boolean;
/**
* The client supports sending will save notifications.
*/
willSave?: boolean;
/**
* The client supports sending a will save request and
* waits for a response providing text edits which will
* be applied to the document before it is saved.
*/
willSaveWaitUntil?: boolean;
/**
* The client supports did save notifications.
*/
didSave?: boolean;
}
/**
* Capabilities specific to the `textDocument/completion`
*/
completion?: {
/**
* Whether completion supports dynamic registration.
*/
dynamicRegistration?: boolean;
/**
* The client supports the following `CompletionItem` specific
* capabilities.
*/
completionItem?: {
/**
* Client supports snippets as insert text.
*
* A snippet can define tab stops and placeholders with `$1`, `$2`
* and `${3:foo}`. `$0` defines the final tab stop, it defaults to
* the end of the snippet. Placeholders with equal identifiers are linked,
* that is typing in one will update others too.
*/
snippetSupport?: boolean;
}
};
/**
* Capabilities specific to the `textDocument/hover`
*/
hover?: {
/**
* Whether hover supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/signatureHelp`
*/
signatureHelp?: {
/**
* Whether signature help supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/references`
*/
references?: {
/**
* Whether references supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/documentHighlight`
*/
documentHighlight?: {
/**
* Whether document highlight supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/documentSymbol`
*/
documentSymbol?: {
/**
* Whether document symbol supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/formatting`
*/
formatting?: {
/**
* Whether formatting supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/rangeFormatting`
*/
rangeFormatting?: {
/**
* Whether range formatting supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/onTypeFormatting`
*/
onTypeFormatting?: {
/**
* Whether on type formatting supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/definition`
*/
definition?: {
/**
* Whether definition supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/codeAction`
*/
codeAction?: {
/**
* Whether code action supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/codeLens`
*/
codeLens?: {
/**
* Whether code lens supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/documentLink`
*/
documentLink?: {
/**
* Whether document link supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
/**
* Capabilities specific to the `textDocument/rename`
*/
rename?: {
/**
* Whether rename supports dynamic registration.
*/
dynamicRegistration?: boolean;
};
}
New:
ClientCapabilities
now define capabilities for dynamic registration, workspace and text document features the client supports. Theexperimental
can be used to pass experimential capabilities under development. For future compatibility aClientCapabilities
object literal can have more properties set than currently defined. Servers receiving aClientCapabilities
object literal with unknown properties should ignore these properties. A missing property should be interpreted as an absence of the capability. If a property is missing that defines sub properties all sub properties should be interpreted as an absence of the capability.
Client capabilities got introduced with the version 3.0 of the protocol. They therefore only describe capabilities that got introduced in 3.x or later. Capabilities that existed in the 2.x version of the protocol are still mandatory for clients. Clients cannot opt out of providing them. So even if a client omits the ClientCapabilities.textDocument.synchronization
it is still required that the client provides text document synchronization (e.g. open, changed and close notifications).
interface ClientCapabilities {
/**
* Workspace specific client capabilities.
*/
workspace?: WorkspaceClientCapabilities;
/**
* Text document specific client capabilities.
*/
textDocument?: TextDocumentClientCapabilities;
/**
* Experimental client capabilities.
*/
experimental?: any;
}
Response:
- result:
InitializeResult
defined as follows:
interface InitializeResult {
/**
* The capabilities the language server provides.
*/
capabilities: ServerCapabilities;
}
- error.code:
/**
* Known error codes for an `InitializeError`;
*/
export namespace InitializeError {
/**
* If the protocol version provided by the client can't be handled by the server.
* @deprecated This initialize error got replaced by client capabilities. There is
* no version handshake in version 3.0x
*/
export const unknownProtocolVersion: number = 1;
}
- error.data:
interface InitializeError {
/**
* Indicates whether the client execute the following retry logic:
* (1) show the message provided by the ResponseError to the user
* (2) user selects retry or cancel
* (3) if user selected retry the initialize method is sent again.
*/
retry: boolean;
}
The server can signal the following capabilities:
/**
* Defines how the host (editor) should sync document changes to the language server.
*/
export namespace TextDocumentSyncKind {
/**
* Documents should not be synced at all.
*/
export const None = 0;
/**
* Documents are synced by always sending the full content
* of the document.
*/
export const Full = 1;
/**
* Documents are synced by sending the full content on open.
* After that only incremental updates to the document are
* send.
*/
export const Incremental = 2;
}
/**
* Completion options.
*/
export interface CompletionOptions {
/**
* The server provides support to resolve additional
* information for a completion item.
*/
resolveProvider?: boolean;
/**
* The characters that trigger completion automatically.
*/
triggerCharacters?: string[];
}
/**
* Signature help options.
*/
export interface SignatureHelpOptions {
/**
* The characters that trigger signature help
* automatically.
*/
triggerCharacters?: string[];
}
/**
* Code Lens options.
*/
export interface CodeLensOptions {
/**
* Code lens has a resolve provider as well.
*/
resolveProvider?: boolean;
}
/**
* Format document on type options
*/
export interface DocumentOnTypeFormattingOptions {
/**
* A character on which formatting should be triggered, like `}`.
*/
firstTriggerCharacter: string;
/**
* More trigger characters.
*/
moreTriggerCharacter?: string[];
}
/**
* Document link options
*/
export interface DocumentLinkOptions {
/**
* Document links have a resolve provider as well.
*/
resolveProvider?: boolean;
}
/**
* Execute command options.
*/
export interface ExecuteCommandOptions {
/**
* The commands to be executed on the server
*/
commands: string[]
}
/**
* Save options.
*/
export interface SaveOptions {
/**
* The client is supposed to include the content on save.
*/
includeText?: boolean;
}
export interface TextDocumentSyncOptions {
/**
* Open and close notifications are sent to the server.
*/
openClose?: boolean;
/**
* Change notificatins are sent to the server. See TextDocumentSyncKind.None, TextDocumentSyncKind.Full
* and TextDocumentSyncKindIncremental.
*/
change?: number;
/**
* Will save notifications are sent to the server.
*/
willSave?: boolean;
/**
* Will save wait until requests are sent to the server.
*/
willSaveWaitUntil?: boolean;
/**
* Save notifications are sent to the server.
*/
save?: SaveOptions;
}
interface ServerCapabilities {
/**
* Defines how text documents are synced. Is either a detailed structure defining each notification or
* for backwards compatibility the TextDocumentSyncKind number.
*/
textDocumentSync?: TextDocumentSyncOptions | number;
/**
* The server provides hover support.
*/
hoverProvider?: boolean;
/**
* The server provides completion support.
*/
completionProvider?: CompletionOptions;
/**
* The server provides signature help support.
*/
signatureHelpProvider?: SignatureHelpOptions;
/**
* The server provides goto definition support.
*/
definitionProvider?: boolean;
/**
* The server provides find references support.
*/
referencesProvider?: boolean;
/**
* The server provides document highlight support.
*/
documentHighlightProvider?: boolean;
/**
* The server provides document symbol support.
*/
documentSymbolProvider?: boolean;
/**
* The server provides workspace symbol support.
*/
workspaceSymbolProvider?: boolean;
/**
* The server provides code actions.
*/
codeActionProvider?: boolean;
/**
* The server provides code lens.
*/
codeLensProvider?: CodeLensOptions;
/**
* The server provides document formatting.
*/
documentFormattingProvider?: boolean;
/**
* The server provides document range formatting.
*/
documentRangeFormattingProvider?: boolean;
/**
* The server provides document formatting on typing.
*/
documentOnTypeFormattingProvider?: DocumentOnTypeFormattingOptions;
/**
* The server provides rename support.
*/
renameProvider?: boolean;
/**
* The server provides document link support.
*/
documentLinkProvider?: DocumentLinkOptions;
/**
* The server provides execute command support.
*/
executeCommandProvider?: ExecuteCommandOptions;
/**
* Experimental server capabilities.
*/
experimental?: any;
}
The initialized notification is sent from the client to the server after the client received the result of the initialize
request but before the client is sending any other request or notification to the server. The server can use the initialized
notification for example to dynamically register capabilities.
Notification:
- method: 'initialized'
- params: void
The shutdown request is sent from the client to the server. It asks the server to shut down, but to not exit (otherwise the response might not be delivered correctly to the client). There is a separate exit notification that asks the server to exit.
Request:
- method: 'shutdown'
- params: void
Response:
- result: null
- error: code and message set in case an exception happens during shutdown request.
A notification to ask the server to exit its process.
The server should exit with success
code 0 if the shutdown request has been received before; otherwise with error
code 1.
Notification:
- method: 'exit'
- params: void
The show message notification is sent from a server to a client to ask the client to display a particular message in the user interface.
Notification:
- method: 'window/showMessage'
- params:
ShowMessageParams
defined as follows:
interface ShowMessageParams {
/**
* The message type. See {@link MessageType}.
*/
type: number;
/**
* The actual message.
*/
message: string;
}
Where the type is defined as follows:
export namespace MessageType {
/**
* An error message.
*/
export const Error = 1;
/**
* A warning message.
*/
export const Warning = 2;
/**
* An information message.
*/
export const Info = 3;
/**
* A log message.
*/
export const Log = 4;
}
The show message request is sent from a server to a client to ask the client to display a particular message in the user interface. In addition to the show message notification the request allows to pass actions and to wait for an answer from the client.
Request:
- method: 'window/showMessageRequest'
- params:
ShowMessageRequestParams
defined as follows:
Response:
- result: the selected
MessageActionItem
- error: code and message set in case an exception happens during showing a message.
interface ShowMessageRequestParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
/**
* The message action items to present.
*/
actions?: MessageActionItem[];
}
Where the MessageActionItem
is defined as follows:
interface MessageActionItem {
/**
* A short title like 'Retry', 'Open Log' etc.
*/
title: string;
}
The log message notification is sent from the server to the client to ask the client to log a particular message.
Notification:
- method: 'window/logMessage'
- params:
LogMessageParams
defined as follows:
interface LogMessageParams {
/**
* The message type. See {@link MessageType}
*/
type: number;
/**
* The actual message
*/
message: string;
}
Where type is defined as above.
The telemetry notification is sent from the server to the client to ask the client to log a telemetry event.
Notification:
- method: 'telemetry/event'
- params: 'any'
The client/registerCapability
request is sent from the server to the client to register for a new capability on the client side. Not all clients need to support dynamic capability registration. A client opts in via the ClientCapabilities.dynamicRegistration
property.
Request:
- method: 'client/registerCapability'
- params:
RegistrationParams
Where RegistrationParams
are defined as follows:
/**
* General parameters to register for a capability.
*/
export interface Registration {
/**
* The id used to register the request. The id can be used to deregister
* the request again.
*/
id: string;
/**
* The method / capability to register for.
*/
method: string;
/**
* Options necessary for the registration.
*/
registerOptions?: any;
}
export interface RegistrationParams {
registrations: Registration[];
}
Since most of the registration options require to specify a document selector there is a base interface that can be used.
export interface TextDocumentRegistrationOptions {
/**
* A document selector to identify the scope of the registration. If set to null
* the document selector provided on the client side will be used.
*/
documentSelector: DocumentSelector | null;
}
An example JSON RPC message to register dynamically for the textDocument/willSaveWaitUntil
feature on the client side is as follows (only details shown):
{
"method": "client/registerCapability",
"params": {
"registrations": [
{
"id": "79eee87c-c409-4664-8102-e03263673f6f",
"method": "textDocument/willSaveWaitUntil",
"registerOptions": {
"documentSelector": [
{ "language": "javascript" }
]
}
}
]
}
}
This message is sent from the server to the client and after the client has successfully executed the request further textDocument/willSaveWaitUntil
requests for JavaScript text documents are sent from the client to the server.
Response:
- result: void.
- error: code and message set in case an exception happens during the request.
The client/unregisterCapability
request is sent from the server to the client to unregister a previously registered capability.
Request:
- method: 'client/unregisterCapability'
- params:
UnregistrationParams
Where UnregistrationParams
are defined as follows:
/**
* General parameters to unregister a capability.
*/
export interface Unregistration {
/**
* The id used to unregister the request or notification. Usually an id
* provided during the register request.
*/
id: string;
/**
* The method / capability to unregister for.
*/
method: string;
}
export interface UnregistrationParams {
unregisterations: Unregistration[];
}
An example JSON RPC message to unregister the above registered textDocument/willSaveWaitUntil
feature looks like this:
{
"method": "client/unregisterCapability",
"params": {
"unregisterations": [
{
"id": "79eee87c-c409-4664-8102-e03263673f6f",
"method": "textDocument/willSaveWaitUntil"
}
]
}
}
A notification sent from the client to the server to signal the change of configuration settings.
Notification:
- method: 'workspace/didChangeConfiguration',
- params:
DidChangeConfigurationParams
defined as follows:
interface DidChangeConfigurationParams {
/**
* The actual changed settings
*/
settings: any;
}
The document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one.
Notification:
- method: 'textDocument/didOpen'
- params:
DidOpenTextDocumentParams
defined as follows:
interface DidOpenTextDocumentParams {
/**
* The document that was opened.
*/
textDocument: TextDocumentItem;
}
Registration Options: TextDocumentRegistrationOptions
The document change notification is sent from the client to the server to signal changes to a text document. In 2.0 the shape of the params has changed to include proper version numbers and language ids.
Notification:
- method: 'textDocument/didChange'
- params:
DidChangeTextDocumentParams
defined as follows:
interface DidChangeTextDocumentParams {
/**
* The document that did change. The version number points
* to the version after all provided content changes have
* been applied.
*/
textDocument: VersionedTextDocumentIdentifier;
/**
* The actual content changes. The content changes descibe single state changes
* to the document. So if there are two content changes c1 and c2 for a document
* in state S10 then c1 move the document to S11 and c2 to S12.
*/
contentChanges: TextDocumentContentChangeEvent[];
}
/**
* An event describing a change to a text document. If range and rangeLength are omitted
* the new text is considered to be the full content of the document.
*/
interface TextDocumentContentChangeEvent {
/**
* The range of the document that changed.
*/
range?: Range;
/**
* The length of the range that got replaced.
*/
rangeLength?: number;
/**
* The new text of the range/document.
*/
text: string;
}
Registration Options: TextDocumentChangeRegistrationOptions
defined as follows:
/**
* Descibe options to be used when registered for text document change events.
*/
export interface TextDocumentChangeRegistrationOptions extends TextDocumentRegistrationOptions {
/**
* How documents are synced to the server. See TextDocumentSyncKind.Full
* and TextDocumentSyncKindIncremental.
*/
syncKind: number;
}
The document will save notification is sent from the client to the server before the document is actually saved.
Notification:
- method: 'textDocument/willSave'
- params:
WillSaveTextDocumentParams
defined as follows:
/**
* The parameters send in a will save text document notification.
*/
export interface WillSaveTextDocumentParams {
/**
* The document that will be saved.
*/
textDocument: TextDocumentIdentifier;
/**
* The 'TextDocumentSaveReason'.
*/
reason: number;
}
/**
* Represents reasons why a text document is saved.
*/
export namespace TextDocumentSaveReason {
/**
* Manually triggered, e.g. by the user pressing save, by starting debugging,
* or by an API call.
*/
export const Manual = 1;
/**
* Automatic after a delay.
*/
export const AfterDelay = 2;
/**
* When the editor lost focus.
*/
export const FocusOut = 3;
}
Registration Options: TextDocumentRegistrationOptions
The document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable.
Request:
- method: 'textDocument/willSaveWaitUntil'
- params:
WillSaveTextDocumentParams
Response:
- result:
TextEdit[]
- error: code and message set in case an exception happens during the
willSaveWaitUntil
request.
Registration Options: TextDocumentRegistrationOptions
The document save notification is sent from the client to the server when the document was saved in the client.
- method: 'textDocument/didSave'
- params:
DidSaveTextDocumentParams
defined as follows:
interface DidSaveTextDocumentParams {
/**
* The document that was saved.
*/
textDocument: TextDocumentIdentifier;
/**
* Optional the content when saved. Depends on the includeText value
* when the save notifcation was requested.
*/
text?: string;
}
Registration Options: TextDocumentSaveRegistrationOptions
defined as follows:
export interface TextDocumentSaveRegistrationOptions extends TextDocumentRegistrationOptions {
/**
* The client is supposed to include the content on save.
*/
includeText?: boolean;
}
The document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notifaction to be sent.
Notification:
- method: 'textDocument/didClose'
- params:
DidCloseTextDocumentParams
defined as follows:
interface DidCloseTextDocumentParams {
/**
* The document that was closed.
*/
textDocument: TextDocumentIdentifier;
}
Registration Options: TextDocumentRegistrationOptions
The watched files notification is sent from the client to the server when the client detects changes to files watched by the language client.
Notification:
- method: 'workspace/didChangeWatchedFiles'
- params:
DidChangeWatchedFilesParams
defined as follows:
interface DidChangeWatchedFilesParams {
/**
* The actual file events.
*/
changes: FileEvent[];
}
Where FileEvents are described as follows:
/**
* An event describing a file change.
*/
interface FileEvent {
/**
* The file's URI.
*/
uri: DocumentUri;
/**
* The change type.
*/
type: number;
}
/**
* The file event type.
*/
export namespace FileChangeType {
/**
* The file got created.
*/
export const Created = 1;
/**
* The file got changed.
*/
export const Changed = 2;
/**
* The file got deleted.
*/
export const Deleted = 3;
}
Diagnostics notification are sent from the server to the client to signal results of validation runs.
Diagnostics are "owned" by the server so it is the server's responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics:
- if a language is single file only (for example HTML) then diagnostics are cleared by the server when the file is closed.
- if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache).
When a file changes it is the server's responsibility to re-compute diagnostics and push them to the client. If the computed set is empty it has to push the empty array to clear former diagnostics. Newly pushed diagnostics always replace previous pushed diagnostics. There is not merging happening on the client side.
Notification:
- method: 'textDocument/publishDiagnostics'
- params:
PublishDiagnosticsParams
defined as follows:
interface PublishDiagnosticsParams {
/**
* The URI for which diagnostic information is reported.
*/
uri: DocumentUri;
/**
* An array of diagnostic information items.
*/
diagnostics: Diagnostic[];
}
The Completion request is sent from the client to the server to compute completion items at a given cursor position. Completion items are presented in the IntelliSense user interface. If computing full completion items is expensive, servers can additionally provide a handler for the completion item resolve request ('completionItem/resolve'). This request is sent when a completion item is selected in the user interface. A typical use case is for example: the 'textDocument/completion' request doesn't fill in the documentation
property for returned completion items since it is expensive to compute. When the item is selected in the user interface then a 'completionItem/resolve' request is sent with the selected completion item as a param. The returned completion item should have the documentation property filled in.
Request:
- method: 'textDocument/completion'
- params:
TextDocumentPositionParams
Response:
- result:
CompletionItem[] | CompletionList
/**
* Represents a collection of [completion items](#CompletionItem) to be presented
* in the editor.
*/
interface CompletionList {
/**
* This list it not complete. Further typing should result in recomputing
* this list.
*/
isIncomplete: boolean;
/**
* The completion items.
*/
items: CompletionItem[];
}
/**
* Defines whether the insert text in a completion item should be interpreted as
* plain text or a snippet.
*/
namespace InsertTextFormat {
/**
* The primary text to be inserted is treated as a plain string.
*/
export const PlainText = 1;
/**
* The primary text to be inserted is treated as a snippet.
*
* A snippet can define tab stops and placeholders with `$1`, `$2`
* and `${3:foo}`. `$0` defines the final tab stop, it defaults to
* the end of the snippet. Placeholders with equal identifiers are linked,
* that is typing in one will update others too.
*
* See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
*/
export const Snippet = 2;
}
type InsertTextFormat = 1 | 2;
interface CompletionItem {
/**
* The label of this completion item. By default
* also the text that is inserted when selecting
* this completion.
*/
label: string;
/**
* The kind of this completion item. Based of the kind
* an icon is chosen by the editor.
*/
kind?: number;
/**
* A human-readable string with additional information
* about this item, like type or symbol information.
*/
detail?: string;
/**
* A human-readable string that represents a doc-comment.
*/
documentation?: string;
/**
* A string that shoud be used when comparing this item
* with other items. When `falsy` the label is used.
*/
sortText?: string;
/**
* A string that should be used when filtering a set of
* completion items. When `falsy` the label is used.
*/
filterText?: string;
/**
* A string that should be inserted a document when selecting
* this completion. When `falsy` the label is used.
*/
insertText?: string;
/**
* The format of the insert text. The format applies to both the `insertText` property
* and the `newText` property of a provided `textEdit`.
*/
insertTextFormat?: InsertTextFormat;
/**
* An edit which is applied to a document when selecting this completion. When an edit is provided the value of
* `insertText` is ignored.
*
* *Note:* The range of the edit must be a single line range and it must contain the position at which completion
* has been requested.
*/
textEdit?: TextEdit;
/**
* An optional array of additional text edits that are applied when
* selecting this completion. Edits must not overlap with the main edit
* nor with themselves.
*/
additionalTextEdits?: TextEdit[];
/**
* An optional set of characters that when pressed while this completion is active will accept it first and
* then type that character. *Note* that all commit characters should have `length=1` and that superfluous
* characters will be ignored.
*/
commitCharacters?: string[];
/**
* An optional command that is executed *after* inserting this completion. *Note* that
* additional modifications to the current document should be described with the
* additionalTextEdits-property.
*/
command?: Command;
/**
* An data entry field that is preserved on a completion item between
* a completion and a completion resolve request.
*/
data?: any
}
/**
* The kind of a completion entry.
*/
namespace CompletionItemKind {
export const Text = 1;
export const Method = 2;
export const Function = 3;
export const Constructor = 4;
export const Field = 5;
export const Variable = 6;
export const Class = 7;
export const Interface = 8;
export const Module = 9;
export const Property = 10;
export const Unit = 11;
export const Value = 12;
export const Enum = 13;
export const Keyword = 14;
export const Snippet = 15;
export const Color = 16;
export const File = 17;
export const Reference = 18;
}
- error: code and message set in case an exception happens during the completion request.
Registration Options: CompletionRegistrationOptions
options defined as follows:
export interface CompletionRegistrationOptions extends TextDocumentRegistrationOptions {
/**
* The characters that trigger completion automatically.
*/
triggerCharacters?: string[];
/**
* The server provides support to resolve additional
* information for a completion item.
*/
resolveProvider?: boolean;
}
The request is sent from the client to the server to resolve additional information for a given completion item.
Request:
- method: 'completionItem/resolve'
- params:
CompletionItem
Response:
- result:
CompletionItem
- error: code and message set in case an exception happens during the completion resolve request.
The hover request is sent from the client to the server to request hover information at a given text document position.
Request:
- method: 'textDocument/hover'
- params:
TextDocumentPositionParams
Response:
- result:
Hover
defined as follows:
/**
* The result of a hover request.
*/
interface Hover {
/**
* The hover's content
*/
contents: MarkedString | MarkedString[];
/**
* An optional range is a range inside a text document
* that is used to visualize a hover, e.g. by changing the background color.
*/
range?: Range;
}
Where MarkedString
is defined as follows:
/**
* MarkedString can be used to render human readable text. It is either a markdown string
* or a code-block that provides a language and a code snippet. The language identifier
* is sematically equal to the optional language identifier in fenced code blocks in GitHub
* issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
*
* The pair of a language and a value is an equivalent to markdown:
* ```${language}
* ${value}
* ```
*
* Note that markdown strings will be sanitized - that means html will be escaped.
*/
type MarkedString = string | { language: string; value: string };
- error: code and message set in case an exception happens during the hover request.
Registration Options: TextDocumentRegistrationOptions
The signature help request is sent from the client to the server to request signature information at a given cursor position.
Request:
- method: 'textDocument/signatureHelp'
- params:
TextDocumentPositionParams
Response:
- result:
SignatureHelp
defined as follows:
/**
* Signature help represents the signature of something
* callable. There can be multiple signature but only one
* active and only one active parameter.
*/
interface SignatureHelp {
/**
* One or more signatures.
*/
signatures: SignatureInformation[];
/**
* The active signature. If omitted or the value lies outside the
* range of `signatures` the value defaults to zero or is ignored if
* `signatures.length === 0`. Whenever possible implementors should
* make an active decision about the active signature and shouldn't
* rely on a default value.
* In future version of the protocol this property might become
* mandantory to better express this.
*/
activeSignature?: number;
/**
* The active parameter of the active signature. If omitted or the value
* lies outside the range of `signatures[activeSignature].parameters`
* defaults to 0 if the active signature has parameters. If
* the active signature has no parameters it is ignored.
* In future version of the protocol this property might become
* mandantory to better express the active parameter if the
* active signature does have any.
*/
activeParameter?: number;
}
/**
* Represents the signature of something callable. A signature
* can have a label, like a function-name, a doc-comment, and
* a set of parameters.
*/
interface SignatureInformation {
/**
* The label of this signature. Will be shown in
* the UI.
*/
label: string;
/**
* The human-readable doc-comment of this signature. Will be shown
* in the UI but can be omitted.
*/
documentation?: string;
/**
* The parameters of this signature.
*/
parameters?: ParameterInformation[];
}
/**
* Represents a parameter of a callable-signature. A parameter can
* have a label and a doc-comment.
*/
interface ParameterInformation {
/**
* The label of this parameter. Will be shown in
* the UI.
*/
label: string;
/**
* The human-readable doc-comment of this parameter. Will be shown
* in the UI but can be omitted.
*/
documentation?: string;
}
- error: code and message set in case an exception happens during the signature help request.
Registration Options: SignatureHelpRegistrationOptions
defined as follows:
export interface SignatureHelpRegistrationOptions extends TextDocumentRegistrationOptions {
/**
* The characters that trigger signature help
* automatically.
*/
triggerCharacters?: string[];
}
The goto definition request is sent from the client to the server to resolve the definition location of a symbol at a given text document position.
Request:
- method: 'textDocument/definition'
- params:
TextDocumentPositionParams
Response:
- result:
Location
|Location
[] |null
- error: code and message set in case an exception happens during the definition request.
Registration Options: TextDocumentRegistrationOptions
The references request is sent from the client to the server to resolve project-wide references for the symbol denoted by the given text document position.
Request:
- method: 'textDocument/references'
- params:
ReferenceParams
defined as follows:
interface ReferenceParams extends TextDocumentPositionParams {
context: ReferenceContext
}
interface ReferenceContext {
/**
* Include the declaration of the current symbol.
*/
includeDeclaration: boolean;
}
Response:
- result:
Location
[] - error: code and message set in case an exception happens during the reference request.
Registration Options: TextDocumentRegistrationOptions
The document highlight request is sent from the client to the server to resolve a document highlights for a given text document position.
For programming languages this usually highlights all references to the symbol scoped to this file. However we kept 'textDocument/documentHighlight'
and 'textDocument/references' separate requests since the first one is allowed to be more fuzzy. Symbol matches usually have a DocumentHighlightKind
of Read
or Write
whereas fuzzy or textual matches use Text
as the kind.
Request:
- method: 'textDocument/documentHighlight'
- params:
TextDocumentPositionParams
Response:
- result:
DocumentHighlight
[] defined as follows:
/**
* A document highlight is a range inside a text document which deserves
* special attention. Usually a document highlight is visualized by changing
* the background color of its range.
*
*/
interface DocumentHighlight {
/**
* The range this highlight applies to.
*/
range: Range;
/**
* The highlight kind, default is DocumentHighlightKind.Text.
*/
kind?: number;
}
/**
* A document highlight kind.
*/
export namespace DocumentHighlightKind {
/**
* A textual occurrence.
*/
export const Text = 1;
/**
* Read-access of a symbol, like reading a variable.
*/
export const Read = 2;
/**
* Write-access of a symbol, like writing to a variable.
*/
export const Write = 3;
}
- error: code and message set in case an exception happens during the document highlight request.
Registration Options: TextDocumentRegistrationOptions
The document symbol request is sent from the client to the server to return a flat list of all symbols found in a given text document. Neither the document's location range nor the documents container name should be used to reinfer a hierarchy.
Request:
- method: 'textDocument/documentSymbol'
- params:
DocumentSymbolParams
defined as follows:
interface DocumentSymbolParams {
/**
* The text document.
*/
textDocument: TextDocumentIdentifier;
}
Response:
- result:
SymbolInformation
[] defined as follows:
/**
* Represents information about programming constructs like variables, classes,
* interfaces etc.
*/
interface SymbolInformation {
/**
* The name of this symbol.
*/
name: string;
/**
* The kind of this symbol.
*/
kind: number;
/**
* The location of this symbol. The location's range is used by a tool
* to reveal the location in the editor. If the symbol is selected in the
* tool the range's start information is used to position the cursor. So
* the range usually spwans more then the actual symbol's name and does
* normally include thinks like visibility modifiers.
*
* The range doesn't have to denote a node range in the sense of a abstract
* syntax tree. It can therefore not be used to re-construct a hierarchy of
* the symbols.
*/
location: Location;
/**
* The name of the symbol containing this symbol. This information is for
* user interface purposes (e.g. to render a qaulifier in the user interface
* if necessary). It can't be used to re-infer a hierarchy for the document
* symbols.
*/
containerName?: string;
}
/**
* A symbol kind.
*/
export namespace SymbolKind {
export const File = 1;
export const Module = 2;
export const Namespace = 3;
export const Package = 4;
export const Class = 5;
export const Method = 6;
export const Property = 7;
export const Field = 8;
export const Constructor = 9;
export const Enum = 10;
export const Interface = 11;
export const Function = 12;
export const Variable = 13;
export const Constant = 14;
export const String = 15;
export const Number = 16;
export const Boolean = 17;
export const Array = 18;
}
- error: code and message set in case an exception happens during the document symbol request.
Registration Options: TextDocumentRegistrationOptions
The workspace symbol request is sent from the client to the server to list project-wide symbols matching the query string.
Request:
- method: 'workspace/symbol'
- params:
WorkspaceSymbolParams
defined as follows:
/**
* The parameters of a Workspace Symbol Request.
*/
interface WorkspaceSymbolParams {
/**
* A non-empty query string
*/
query: string;
}
Response:
- result:
SymbolInformation[]
as defined above. - error: code and message set in case an exception happens during the workspace symbol request.
Registration Options: void
The code action request is sent from the client to the server to compute commands for a given text document and range. These commands are typically code fixes to either fix problems or to beautify/refactor code.
Request:
- method: 'textDocument/codeAction'
- params:
CodeActionParams
defined as follows:
/**
* Params for the CodeActionRequest
*/
interface CodeActionParams {
/**
* The document in which the command was invoked.
*/
textDocument: TextDocumentIdentifier;
/**
* The range for which the command was invoked.
*/
range: Range;
/**
* Context carrying additional information.
*/
context: CodeActionContext;
}
/**
* Contains additional diagnostic information about the context in which
* a code action is run.
*/
interface CodeActionContext {
/**
* An array of diagnostics.
*/
diagnostics: Diagnostic[];
}
Response:
- result:
Command[]
defined as follows: - error: code and message set in case an exception happens during the code action request.
Registration Options: TextDocumentRegistrationOptions
The code lens request is sent from the client to the server to compute code lenses for a given text document.
Request:
- method: 'textDocument/codeLens'
- params:
CodeLensParams
defined as follows:
interface CodeLensParams {
/**
* The document to request code lens for.
*/
textDocument: TextDocumentIdentifier;
}
Response:
- result:
CodeLens[]
defined as follows:
/**
* A code lens represents a command that should be shown along with
* source text, like the number of references, a way to run tests, etc.
*
* A code lens is _unresolved_ when no command is associated to it. For performance
* reasons the creation of a code lens and resolving should be done in two stages.
*/
interface CodeLens {
/**
* The range in which this code lens is valid. Should only span a single line.
*/
range: Range;
/**
* The command this code lens represents.
*/
command?: Command;
/**
* A data entry field that is preserved on a code lens item between
* a code lens and a code lens resolve request.
*/
data?: any
}
- error: code and message set in case an exception happens during the code lens request.
Registration Options: CodeLensRegistrationOptions
defined as follows:
export interface CodeLensRegistrationOptions extends TextDocumentRegistrationOptions {
/**
* Code lens has a resolve provider as well.
*/
resolveProvider?: boolean;
}
The code lens resolve request is sent from the client to the server to resolve the command for a given code lens item.
Request:
- method: 'codeLens/resolve'
- params:
CodeLens
Response:
- result:
CodeLens
- error: code and message set in case an exception happens during the code lens resolve request.
The document links request is sent from the client to the server to request the location of links in a document.
Request:
- method: 'textDocument/documentLink'
- params:
DocumentLinkParams
, defined as follows
interface DocumentLinkParams {
/**
* The document to provide document links for.
*/
textDocument: TextDocumentIdentifier;
}
Response:
- result: An array of
DocumentLink
, ornull
.
/**
* A document link is a range in a text document that links to an internal or external resource, like another
* text document or a web site.
*/
interface DocumentLink {
/**
* The range this link applies to.
*/
range: Range;
/**
* The uri this link points to. If missing a resolve request is sent later.
*/
target?: DocumentUri;
}
- error: code and message set in case an exception happens during the document link request.
Registration Options: DocumentLinkRegistrationOptions
defined as follows:
export interface DocumentLinkRegistrationOptions extends TextDocumentRegistrationOptions {
/**
* Document links have a resolve provider as well.
*/
resolveProvider?: boolean;
}
The document link resolve request is sent from the client to the server to resolve the target of a given document link.
Request:
- method: 'documentLink/resolve'
- params:
DocumentLink
Response:
- result:
DocumentLink
- error: code and message set in case an exception happens during the document link resolve request.
The document formatting request is sent from the server to the client to format a whole document.
Request:
- method: 'textDocument/formatting'
- params:
DocumentFormattingParams
defined as follows
interface DocumentFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The format options.
*/
options: FormattingOptions;
}
/**
* Value-object describing what options formatting should use.
*/
interface FormattingOptions {
/**
* Size of a tab in spaces.
*/
tabSize: number;
/**
* Prefer spaces over tabs.
*/
insertSpaces: boolean;
/**
* Signature for further properties.
*/
[key: string]: boolean | number | string;
}
Response:
- result:
TextEdit[]
describing the modification to the document to be formatted. - error: code and message set in case an exception happens during the formatting request.
Registration Options: TextDocumentRegistrationOptions
The document range formatting request is sent from the client to the server to format a given range in a document.
Request:
- method: 'textDocument/rangeFormatting',
- params:
DocumentRangeFormattingParams
defined as follows:
interface DocumentRangeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The range to format
*/
range: Range;
/**
* The format options
*/
options: FormattingOptions;
}
Response:
- result:
TextEdit[]
describing the modification to the document to be formatted. - error: code and message set in case an exception happens during the range formatting request.
Registration Options: TextDocumentRegistrationOptions
The document on type formatting request is sent from the client to the server to format parts of the document during typing.
Request:
- method: 'textDocument/onTypeFormatting'
- params:
DocumentOnTypeFormattingParams
defined as follows:
interface DocumentOnTypeFormattingParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was sent.
*/
position: Position;
/**
* The character that has been typed.
*/
ch: string;
/**
* The format options.
*/
options: FormattingOptions;
}
Response:
- result:
TextEdit[]
describing the modification to the document. - error: code and message set in case an exception happens during the range formatting request.
Registration Options: DocumentOnTypeFormattingRegistrationOptions
defined as follows:
export interface DocumentOnTypeFormattingRegistrationOptions extends TextDocumentRegistrationOptions {
/**
* A character on which formatting should be triggered, like `}`.
*/
firstTriggerCharacter: string;
/**
* More trigger characters.
*/
moreTriggerCharacter?: string[]
}
The rename request is sent from the client to the server to perform a workspace-wide rename of a symbol.
Request:
- method: 'textDocument/rename'
- params:
RenameParams
defined as follows
interface RenameParams {
/**
* The document to format.
*/
textDocument: TextDocumentIdentifier;
/**
* The position at which this request was sent.
*/
position: Position;
/**
* The new name of the symbol. If the given name is not valid the
* request must return a [ResponseError](#ResponseError) with an
* appropriate message set.
*/
newName: string;
}
Response:
- result:
WorkspaceEdit
describing the modification to the workspace. - error: code and message set in case an exception happens during the rename request.
Registration Options: TextDocumentRegistrationOptions
The workspace/executeCommand
request is sent from the client to the server to trigger command execution on the server. In most cases
the server creates a WorkspaceEdit
structure and applies the changes to the workspace using the request workspace/applyEdit
which is
sent from the server to the client.
Request:
- method: 'workspace/executeCommand'
- params:
ExecuteCommandParams
defined as follows:
export interface ExecuteCommandParams {
/**
* The identifier of the actual command handler.
*/
command: string;
/**
* Arguments that the command should be invoked with.
*/
arguments?: any[];
}
The arguments are typically specified when a command is returned from the server to the client. Example requests that return a command are textDocument/codeAction
or textDocument/codeLens
.
Response:
- result: any
- error: code and message set in case an exception happens during the request.
Registration Options: ExecuteCommandRegistrationOptions
defined as follows:
/**
* Execute command registration options.
*/
export interface ExecuteCommandRegistrationOptions {
/**
* The commands to be executed on the server
*/
commands: string[]
}
The workspace/applyEdit
request is sent from the server to the client to modify resource on the client side.
Request:
- method: 'workspace/applyEdit'
- params:
ApplyWorkspaceEditParams
defined as follows:
export interface ApplyWorkspaceEditParams {
/**
* The edits to apply.
*/
edit: WorkspaceEdit;
}
Response:
- result:
ApplyWorkspaceEditResponse
defined as follows:
export interface ApplyWorkspaceEditResponse {
/**
* Indicates whether the edit was applied or not.
*/
applied: boolean;
}
- error: code and message set in case an exception happens during the request.