VS Code Server
Relevant source files
The following files were used as context for generating this wiki page:
- extensions/html-language-features/server/package.json
- extensions/css-language-features/server/package.json
- extensions/json-language-features/server/package.json
- extensions/typescript-language-features/package.nls.json
- extensions/markdown-language-features/package.json
- extensions/github/package.json
- extensions/github-authentication/package.json
VS Code employs a server-based architecture for many of its core features, most notably for providing rich language support. This model involves running language-specific logic in a separate server process, which communicates with the main VS Code client. This separation enhances performance, stability, and modularity by isolating intensive tasks like code analysis, completion, and validation from the UI thread.
The primary implementation of this pattern is through Language Servers, which are defined in various language feature extensions such as HTML, CSS, JSON, and TypeScript. These servers are responsible for the "IntelliSense" capabilities of VS Code. Additionally, other extensions, like those for authentication, may also use server-side components to handle specific tasks like managing OAuth flows.
Architecture
The core architectural pattern involves the main VS Code application acting as a client that communicates with one or more server processes. Each server is specialized for a particular language or functionality.
This diagram illustrates the high-level communication flow between the VS Code client and its various language servers.
Language Servers
Language servers are a key part of the VS Code server architecture. They are typically defined within an extension's package.json and have their own dependencies and entry points.
Language Server Implementations
Several built-in extensions provide language servers for core web technologies.
| Language Server | Description | Main Entry Point | Key Dependencies | Source File |
|---|---|---|---|---|
| HTML | Provides language support for HTML. | ./out/node/htmlServerMain | vscode-languageserver, vscode-html-languageservice | extensions/html-language-features/server/package.json |
| CSS/LESS/SCSS | Provides language support for CSS, LESS, and SCSS. | ./out/node/cssServerMain | vscode-languageserver, vscode-css-languageservice | extensions/css-language-features/server/package.json |
| JSON | Provides language support for JSON. | ./out/node/jsonServerMain | vscode-languageserver, vscode-json-languageservice, jsonc-parser | extensions/json-language-features/server/package.json |
| Markdown | Provides language support for Markdown. | (via vscode-languageclient) | vscode-languageclient, vscode-markdown-languageserver | extensions/markdown-language-features/package.json |
Sources: extensions/html-language-features/server/package.json:10,12-15, extensions/css-language-features/server/package.json:10,13-15, extensions/json-language-features/server/package.json:13,15-19, extensions/markdown-language-features/package.json:302-304
TypeScript Server (TSServer)
The TypeScript language server, known as TSServer, is one of the most feature-rich servers in VS Code. It provides extensive IntelliSense for both TypeScript and JavaScript. Its behavior can be heavily configured through user and workspace settings.
Key TSServer Configurations
| Configuration | Description |
|---|---|
typescript.tsserver.log | Enables logging of the TS server to a file for diagnosing issues. |
typescript.tsserver.trace | Enables tracing of messages sent to the TS server. |
typescript.tsserver.maxTsServerMemory | The maximum amount of memory (in MB) to allocate to the TypeScript server process. |
configuration.tsserver.useSeparateSyntaxServer | Enables spawning a separate, lightweight TypeScript server for syntax-related operations to improve responsiveness. |
configuration.tsserver.watchOptions | Configures file watching strategies used by the server to detect changes. |
configuration.tsserver.web.projectWideIntellisense.enabled | Enables or disables project-wide IntelliSense on the web. |
Sources: extensions/typescript-language-features/package.nls.json:18,20,90,84,180,211
This sequence diagram shows a typical interaction for obtaining code completions.
Server-Side Authentication
VS Code also leverages server-side components for handling authentication flows, such as with GitHub. The github-authentication extension defines providers for both public GitHub and GitHub Enterprise Server.
This is configured in the contributes.authentication section of its package.json. It specifies authorization server endpoints that it can handle.
| Provider Label | ID | Authorization Server Globs |
|---|---|---|
| GitHub | github | https://github.com/login/oauth |
| GitHub Enterprise Server | github-enterprise | * |
Sources: extensions/github-authentication/package.json:33-44
The configuration also allows specifying the URI for a GitHub Enterprise instance, which is a restricted setting that requires workspace trust.
Sources: extensions/github-authentication/package.json:25-28,48-52
Server Diagnostics and Tracing
To aid in development and troubleshooting, many language servers expose configuration options for logging and tracing communication between the VS Code client and the server process.
| Language | Configuration Setting | Description |
|---|---|---|
| Markdown | markdown.trace.server | Traces communication between VS Code and the Markdown language server. Can be set to off, messages, or verbose. |
| Markdown | markdown.server.log | Controls the logging level of the Markdown language server. Can be set to off, debug, or trace. |
| TypeScript | typescript.tsserver.log | Enables logging of the TS server to a file. |
| TypeScript | typescript.tsserver.trace | Enables tracing of messages sent to the TS server. |
| CSS/LESS/SCSS | css.trace.server | Traces the communication between VS Code and the CSS language server. |
Sources: extensions/markdown-language-features/package.json:188-197, extensions/typescript-language-features/package.nls.json:18,20, extensions/css-language-features/package.nls.json:28
Summary
The VS Code Server architecture is a fundamental design choice that delegates complex, language-specific, or sensitive operations to external processes. This is most prominently seen in the implementation of Language Servers for features like HTML, CSS, JSON, and TypeScript, which power the core editing experience. This modular, server-based approach not only improves the performance and reliability of the editor but also provides a clear pattern for extensibility, allowing third-party developers to contribute rich language support and other server-driven features to the VS Code ecosystem.