vscode-languageserver-node

repository·main·Indexed 23 days ago

https://github.com/microsoft/vscode-languageserver-node

A collection of Node.js modules for implementing and consuming the Language Server Protocol (LSP). It includes vscode-languageclient for VSCode extension integration, vscode-languageserver for server implementation, vscode-jsonrpc for base messaging, and supporting modules like vscode-languageserver-protocol and vscode-languageserver-types.

Tokens
49.1K
Snippets
62
Records
279
Agent score
82%

What's inside vscode-languageserver-node

  1. Overview of VSCode Language Server - Node modules

    main

    The vscode-languageserver-node repository provides several npm modules for building and consuming Language Server Protocol (LSP) implementations in Node.js:

    • vscode-languageclient: Used by a VSCode extension to communicate with a language server.
    • vscode-languageserver: Used to implement the language server itself using Node.js.
    • vscode-languageserver-textdocument: Provides text document implementations for use within an LSP server.
    • vscode-languageserver-protocol: Contains the TypeScript definitions for the Language Server Protocol.
    • vscode-languageserver-types: Contains the data types used by both the client and the server.
    • vscode-jsonrpc: The underlying JSON-RPC message protocol used for communication between the client and server.
  2. Overview of TS-Config generator

    main

    The tsconfig-gen tool helps maintain consistent tsconfig.json files in monorepos. Instead of manually managing multiple files, you define a high-level configuration that the generator uses to produce specific configurations.

    Key capabilities include:

    • Multiple Base Configurations: Extending from several base configs simultaneously.
    • Project Dependency Management: Automatically generating proper references based on project dependencies.
    • Source Folder Specialization: Generating different compiler configurations for specific source folders within a project (e.g., creating separate configs for common, browser, or node code).
    • Lifecycle-based Configurations: Generating distinct compiler settings for different tasks like compile, watch, or publish.
  3. Protocol changes in version 3.18.0

    main

    Version 3.18.0 introduced several new requests, notifications, and features to the Language Server Protocol (LSP) implementation. Key updates include:

    New Requests and Notifications

    • textDocument/inlineCompletion: Supports inline completion requests and registration.
    • workspace/textDocumentContent & workspace/textDocumentContent/refresh: Allows servers to provide dynamic text content for custom schemes.
    • textDocument/rangesFormatting: Enables formatting multiple ranges in a single request.
    • workspace/foldingRange/refresh: Allows server-initiated folding-range refreshes.
    • Notebook support: Added diagnostic pull and notebookCodeActionKind support.

    Key Feature Updates

    • Workspace Edits: WorkspaceEdit now supports SnippetTextEdit. WorkspaceEditMetadata is available via ApplyWorkspaceEditParams.metadata (includes isRefactoring).
    • Completion: CompletionList.itemDefaults now includes data. A new applyKind (Replace | Merge) controls how list defaults merge with individual items.
    • Code Actions: Added CodeAction.tags (including LLMGenerated) and CodeActionOptions.documentation.
    • Rename: PrepareRenameResult is now reified into PrepareRenamePlaceholder and PrepareRenameDefaultBehavior.
    • Diagnostics: Diagnostic.message can now be MarkupContent.
    • Semantic Tokens: SemanticTokenTypes.label added; types and modifiers are now treated as an open set.
    • Markdown: Added supportThemeIcons and extended trusted markdown command lists.
  4. Implement a VSCode language server with Node.js

    main

    The vscode-languageserver npm module provides the necessary tools to implement a Language Server (LSP) using Node.js as the runtime. This allows you to build language intelligence features (like autocompletion, go-to-definition, and diagnostics) that can be consumed by VS Code and other LSP-compatible editors.

    For a comprehensive step-by-step guide on implementation, refer to the official VS Code documentation: Example Language Server.

  5. Integrate language servers into VSCode extensions using vscode-languageclient

    main

    The vscode-languageclient npm module provides a high-level API for VSCode extensions to integrate with language servers that implement the Language Server Protocol (LSP). It handles the communication lifecycle between the VSCode client and the external language server process.

    For a comprehensive implementation guide, refer to the official VSCode documentation: Example Language Server.

  6. Use the VSCode Language Server - Protocol Module

    main

    The vscode-languageserver-protocol module is a tool-independent implementation of the Language Server Protocol (LSP). It can be used in any Node.js application to implement or consume LSP-compliant communication.

    Important Versioning Note: This module versions its releases based on the LSP specification version number. Because the protocol implementation depends on vscode-jsonrpc, breaking changes in the JSON-RPC dependency might not always trigger a major version bump in this module. This is done to maintain alignment between the module's version and the official LSP specification version, avoiding version mismatch confusion.

  7. Use vscode-languageserver-textdocument for LSP Node servers

    main

    The vscode-languageserver-textdocument npm module provides a simple text document implementation designed for use within Node.js-based Language Servers (LSP). It allows your server to manage and interact with text documents in a way that is compatible with the Language Server Protocol (LSP) requirements.

    For a comprehensive guide on implementing a full language server for VSCode, refer to the official VSCode documentation: https://code.visualstudio.com/docs/extensions/example-language-server

  8. Document Filters: Glob Patterns and Notebook Support

    main

    Document selection and filtering have been updated:

    • Typed Filters: DocumentFilter and NotebookDocumentFilter are now reified into specific variants like ...FilterLanguage, ...FilterScheme, and ...FilterPattern.
    • Glob Patterns: The pattern field now uses GlobPattern, allowing registrations to use RelativePattern. This is gated by TextDocumentFilterClientCapabilities.relativePatternSupport.
    • Notebook Filters: Added NotebookDocumentFilterNotebookType, ...Scheme, and ...Pattern.
  9. Handle LanguageClient request/notification registration in 3.17.0+

    main
    Starting with version 3.17.0, you can register notification and request handlers before the client has started. This prevents missing messages sent by the server during initialization. Additionally, if an extension sends a notification or request before the client is started, the client will automatically trigger its start() sequence.
  10. Markdown: Theme Icons and Trusted Commands

    main

    Markdown support in the protocol has been enhanced:

    • Theme Icons: Clients can signal support for icon syntax $(name) via MarkdownClientCapabilities.supportThemeIcons.
    • Trusted Markdown: For areas where servers return markdown (hover, signature help, etc.), the isTrusted mechanism has been extended. Servers can provide a list of enabledCommands via the Command type to define which commands are safe to run in a trusted context.
  11. Completion: Per-item Defaults and Merge Strategies

    main

    The completion protocol has been updated to allow more granular control over how completion items are merged:

    • Item Defaults: CompletionList.itemDefaults is extended with a data field, allowing for per-item default data payloads.
    • Merge Strategy: A new CompletionList.applyKind (of type CompletionItemApplyKinds) defines how commitCharacters and data are merged between list defaults and individual items. Supported strategies are Replace and Merge. This is gated by the completionList.applyKindSupport client capability.
  12. Workspace Edits: Snippet Support and Metadata

    main

    The WorkspaceEdit object has been enhanced with the following capabilities:

    • Snippet Support: WorkspaceEdit can now carry SnippetTextEdit entries. Clients can check for this via the workspace.workspaceEdit.snippetEditSupport capability.
    • Metadata: WorkspaceEditMetadata can be carried in ApplyWorkspaceEditParams.metadata. This is gated by the workspace.workspaceEdit.metadataSupport client capability and currently includes an isRefactoring field.
    • Command Tooltips: The Command type now supports a proposed tooltip field.