This repository contains the code for the following npm modules:
All npm modules are built using one Azure Pipeline. Its status is:
Click here for a detailed document on how to use these npm modules to implement language servers for VSCode.
After cloning the repository, run npm install
to install dependencies and npm run symlink
to point packages in this repository to each other.
5.5.x
.20.9.0
and es2022
. See also TypeScript's node target mapping.vscode-jsonrpc
, vscode-languageserver-protocol
, vscode-languageclient
and vscode-languageserver
now use the exports
property instead of having a main
and typings
property. This might need adoption in tsconfig.json files around the module
and moduleResolution
. The LSP libraries currently use node16
for both values.CancellationToken
to the show document middleware to make it consistent with the other middleware. This is a breaking change since it added a required parameter.client.getFeature(lsclient.FoldingRangeRequest.method).getProvider(document)?.provider;
Library specific changes are:
start
and stop
methods. Both methods now return a promise since these methods are async. This is a breaking change since start returned a disposable before. Extensions should now implement a deactivate function in their extension main file and correctly return the stop
promise from the deactivate call. As a consequence the onReady()
got removed since extensions can await the start()
call now. Old code like this
const client: LanguageClient = ...;
client.start();
await client.onReady();
should become:
const client: LanguageClient = ...;
await client.start();
sendNotification
methods now return a promise. Returning a promise was necessary since the actual writing of the message to the underlying transport is async and a client for example could not determine if a notification was handed off to the transport. This is a breaking change in the sense that it might result in floating promise and might be flagged by a linter.handleFailedRequest
has change. Instead of returning a default value when a exception is received from the server the method now rethrows the error. This ensures that VS Code's default behavior on errors is used. The method also handles the RequestCancelled
and ServerCancelled
in the following way:
ServerCancelled
and the client didn't cancel the request as well throw CancellationError to ask the client to rerun the request.RequestCancelled
then normally the client should have cancelled the request and the code will return the default value (according to the best interpretation of the 3.16 spec). If the client has not canceled interpret the RequestCancelled
as ServerCancelled
.null
). This is a breaking change since in former releases of the library the middleware would see the result also not used by VS Code. The change was made to save CPU and memory by not converting unused response results.For a detailed list of changes made in the 3.16.0 version of the protocol see the change log of the 3.16 specification.
Library specific changes are:
messages
property to registrationType
and return a corresponding RegistrationType
. Additional remove the first parameter from the register
method.ErrorCodes
. LSP specific error codes got moved to a new namespace LSPErrorCodes
. The namespace ErrorCodes
in jsonrpc
is not correctly reserved for JSON RPC specific error codes. This is a breaking change. To resolve it use LSPErrorCodes
instead.vscode-jsonrpc
for an example: (a) the import vscode-jsonrpc
will only import the common code, (b) the import vscode-jsonrpc\node
will import the common and the node code and (c) the import vscode-jsonrpc\browser
will import the common and browser code.vscode-jsonrpc
. The parameter structure can be controlled using the additional parameterStructures
argument when creating a request or notification type or when sending an untyped request or notification using the sendRequest
or sendNotification
function. The default is ParameterStructures.auto
which does the following:
byPosition
for messages with zero or greater than one parameterbyName
for parameters which are object literals. Uses byPosition
for all other parameters.SelectionRangeRequest
protocol added:
SelectionRange
SelectionRangeRequest
, SelectionRangeParams
, SelectionRangeClientCapabilities
, SelectionRangeServerCapabilities
, SelectionRangeProviderOptions
,vscode-languageserver-textdocument
which ships a standard text document implementation with basic incremental update. Server now need to pre-requisite this npm package.new TextDocuments
you now have to pass in a text document configuration to provide callbacks to create and update a text document. Here are examples in TypeScript and JavaScriptimport { TextDocuments } from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver-textdocument';
const documents = new TextDocuments(TextDocument);
const server = require("vscode-languageserver");
const textDocument = require("vscode-languageserver-textdocument");
const documents = new server.TextDocuments(textDocument.TextDocument);
FoldingRangeRequestParam
renamed to 'FoldingRangeParams' (FoldingRangeRequestParam
still provided for backward compatibility)engines.vscode
in the package.json
file matches the VS Code version the client is running on.Color
, ColorInformation
, ColorPresentation
moved to TypesFoldingRangeRequest
protocol added:
FoldingRange
, FoldingRangeKind
FoldingRangeRequest
, FoldingRangeRequestParam
, FoldingRangeClientCapabilities
, FoldingRangeServerCapabilities
, FoldingRangeProviderOptions
,preselect
property on CompletionItem
Add support for related information in diagnostics.
implemented the latest protocol additions. Noteworthy are completion context, extensible completion item and symbol kind as well as markdown support for completion item and signature help. Moved to 4.0.0 version since the introduction of the completion context required a breaking change in the client middleware. The old signature:
provideCompletionItem?: (this: void, document: TextDocument, position: VPosition, token: CancellationToken, next: ProvideCompletionItemsSignature) => ProviderResult<VCompletionItem[] | VCompletionList>;
contains now an additional argument context
:
provideCompletionItem?: (this: void, document: TextDocument, position: VPosition, context: VCompletionContext, token: CancellationToken, next: ProvideCompletionItemsSignature) => ProviderResult<VCompletionItem[] | VCompletionList>;
Noteworthy fixes:
vscode-languageserver-protocol
has been added which contains the protocol definitions in TypeScript. This module is now shared between the client and the server.protocol
, client
and server
npm modules. Proposed protocol is subject to change even if it ships in a stable version of the npm modules.WorkspaceEdit
conform to the 3.x version of the spec and backwards compatible with 2.x version of the library.RequestCancelled
error code.Files.uriToFilePath
in favour of the vscode-uri npm module which provides a more complete implementation of URI for VS Code.rootPath
optional since it is deprecated in 3.x.client/registerCapability
and client/unregisterCapability
.workspace/executeCommand
to the server.InsertTextFormat
let client = new LanguageClient(...);
client.onReady().then(() => {
client.onNotification(...);
client.sendRequest(...);
);
// Old
import { Protocol2Code, ... } from 'vscode-languageclient';
Protocol2Code.asTextEdits(edits);
// New
let client = new LanguageClient(...);
client.protocol2CodeConverter.asTextEdits(edits);
LanguageClient
is used in a VS Code extension. You can find detailed steps on how to upgrade a VS Code extension to TypeScript 2.x.x here.activeSignature
and activeParameter
where incorrectly declared as optional in SignatureHelp
. They are now mandatory.protocol.ts
file used enum types in 2.x. However the protocol itself is number based since no assumption can be made about the presence of an enum type in the implementing language. To make this more clear the enum got replace by number types with a or literal type definition. This might result in compile errors if a number was directly assigned to a previous enum type without a proper range check.RequestType
or NotificationType
and add void as the registration option type. Please remember to update this on both the client and server side:// Old
export namespace MyRequest {
export const type: RequestType<MyParams, MyResult, void> = { get method() { return 'myRequest'; } };
}
export namespace MyNotification {
export const type: NotificationType<MyParams> = { get method() { return 'myNotification'; } };
}
// New
export namespace MyRequest {
export const type = new RequestType<MyParams, MyResult, void, void>('myRequest');
}
export namespace MyNotification {
export const type = new NotificationType<MyParams, void>('myNotification');
}
LanguageClientOptions.errorHandler
). The default strategy restart the server unless it crashed 5 times or more in the last 3 minutes.