Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
vscode-languageclient
Advanced tools
The vscode-languageclient npm package is a library that helps in creating language clients for Visual Studio Code extensions. It facilitates communication between the client (VS Code) and the language server, enabling features like auto-completion, go-to-definition, and diagnostics.
Initialize Language Client
This code initializes a language client that communicates with a language server. The client is configured to listen to plaintext files and synchronize file events.
const { LanguageClient, TransportKind } = require('vscode-languageclient/node');
const client = new LanguageClient(
'languageServerExample',
'Language Server Example',
{
command: 'path/to/language-server',
args: [],
transport: TransportKind.stdio
},
{
documentSelector: [{ scheme: 'file', language: 'plaintext' }],
synchronize: {
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
}
);
client.start();
Handle Server Notifications
This code sets up a handler for custom notifications sent from the language server to the client. It logs the received notification parameters to the console.
client.onReady().then(() => {
client.onNotification('custom/notification', (params) => {
console.log('Received custom notification:', params);
});
});
Send Custom Requests
This code sends a custom request from the client to the language server and logs the server's response.
client.onReady().then(() => {
client.sendRequest('custom/request', { text: 'Hello, server!' }).then((response) => {
console.log('Received response:', response);
});
});
The vscode-languageserver package provides tools to implement a language server. It is often used in conjunction with vscode-languageclient to create a full language server-client setup. While vscode-languageclient is focused on the client-side, vscode-languageserver provides the server-side implementation.
The monaco-languageclient package is similar to vscode-languageclient but is designed for use with the Monaco Editor, which is the editor that powers VS Code. It allows for language server communication in web-based editors, providing similar functionalities to vscode-languageclient but in a different environment.
The lsp-client package is a lightweight alternative to vscode-languageclient. It provides basic functionalities to communicate with language servers using the Language Server Protocol (LSP). It is less feature-rich but can be a good choice for simpler use cases.
This npm module allows VSCode extensions to easily integrate language servers adhering to the language server protocol
See here for a detailed documentation on how to implement language servers for VSCode.
For the history please see the main repository
FAQs
VSCode Language client implementation
We found that vscode-languageclient demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.