Welcome to Code - OSS
Relevant source files
The following files were used as context for generating this wiki page:
- extensions/typescript-language-features/package.nls.json
- extensions/markdown-language-features/package.json
- extensions/markdown-language-features/package.nls.json
- extensions/github/package.json
- extensions/github-authentication/package.json
- extensions/html-language-features/cgmanifest.json
- extensions/yaml/syntaxes/yaml.tmLanguage.json
- extensions/markdown-basics/package.json
- extensions/gulp/package.json
- extensions/make/package.json
- extensions/markdown-math/package.json
- extensions/restructuredtext/syntaxes/rst.tmLanguage.json
- test/integration/browser/package.json
Code - OSS is an extensible code editor that provides rich language support and tooling through a robust extension model. The core editor is enhanced by a collection of built-in extensions that offer features ranging from language intelligence for TypeScript and JavaScript to syntax highlighting for a multitude of languages, and integration with services like GitHub. This document provides an overview of its architecture, focusing on the key extensions and contribution points that define its functionality.
The system is designed around a central concept of "contributions," where extensions declare their capabilities in a package.json manifest. These contributions can include commands, language configurations, syntax grammars, task definitions, and UI elements like menus and views. This modular approach allows for a highly customizable and powerful development environment.
Core Architecture: The Extension Model
The power of Code - OSS lies in its extension model. Each piece of functionality, from basic language coloring to complex debugging, is provided by an extension. An extension's capabilities are declared in its package.json manifest file through the contributes object.
This diagram illustrates the relationship between the VS Code core and various types of extensions that plug into it.
Bundled Language Features
Code - OSS includes several powerful language feature extensions out of the box. These provide much more than just syntax highlighting, including IntelliSense, validation, and rich editing commands.
TypeScript and JavaScript
This is one of the most comprehensive bundled extensions, providing rich language support for both JavaScript and TypeScript. It is powered by the TypeScript server (TSServer).
Sources: extensions/typescript-language-features/package.nls.json:2-3
Key Features & Configurations
The extension offers a vast array of configuration options to tailor the editing experience.
| Feature | Description | Configuration Key |
|---|---|---|
| TSDK Path | Specifies the folder path to a TypeScript installation to use for IntelliSense. | typescript.tsdk |
| Validation | Enable or disable TypeScript and JavaScript validation. | typescript.validate.enable, javascript.validate.enable |
| Formatting | Enable or disable the default formatters and configure detailed spacing rules. | typescript.format.enable, javascript.format.enable |
| Auto Imports | Enable or disable auto import suggestions. | configuration.suggest.autoImports |
| Inlay Hints | Show inlay hints for parameter names, variable types, and more. | configuration.inlayHints.* |
| CodeLens | Show references CodeLens above classes and functions. | typescript.referencesCodeLens.enabled |
| Automatic Type Acquisition | Fetches @types packages from npm to improve IntelliSense for external libraries. | typescript.disableAutomaticTypeAcquisition |
Sources: extensions/typescript-language-features/package.nls.json:10-217
Markdown
Markdown support is split across multiple extensions, including markdown-basics for syntax and markdown-language-features for advanced functionality.
Sources: extensions/markdown-basics/package.json:2-4, extensions/markdown-language-features/package.json:2-4
Markdown Preview
A core feature is the live preview of Markdown files, which can be opened to the side of the editor. The preview's behavior is highly configurable.
The following diagram shows the flow for opening and configuring the Markdown preview.
Link and File Path Management
The Markdown extension provides robust tools for managing links and file paths, including validation and automatic updates.
| Feature | Description | Configuration Key |
|---|---|---|
| Path Suggestions | Enable path suggestions when writing links. | markdown.suggest.paths.enabled |
| Link Validation | Validate reference links, fragment links, and file links. | markdown.validate.enabled, markdown.validate.fileLinks.enabled |
| Update on File Move | Automatically update links in Markdown files when a file is renamed or moved. | markdown.updateLinksOnFileMove.enabled |
| File Drop/Paste | Control how files dropped or pasted into a Markdown editor are handled, including copying them into the workspace. | markdown.editor.drop.enabled, markdown.copyFiles.destination |
Sources: extensions/markdown-language-features/package.nls.json:44-89
The markdown-math extension further enhances Markdown capabilities by adding support for rendering mathematical formulas using KaTeX. It contributes a notebook renderer and injects grammars into the main Markdown language.
Sources: extensions/markdown-math/package.json:27-71
Syntax Highlighting
Syntax highlighting is provided via TextMate grammars (.tmLanguage.json files). These grammars define tokenization rules for a given language. An extension contributes a grammar by specifying its language ID, scope name, and the path to the grammar file.
Grammar Contribution
This is an example of how the makefile language is defined and associated with its grammar.
{
"contributes": {
"languages": [
{
"id": "makefile",
"aliases": [ "Makefile", "makefile" ],
"extensions": [ ".mak", ".mk" ],
"filenames": [ "Makefile", "makefile", "GNUmakefile", "OCamlMakefile" ]
}
],
"grammars": [
{
"language": "makefile",
"scopeName": "source.makefile",
"path": "./syntaxes/make.tmLanguage.json"
}
]
}
}
Sources: extensions/make/package.json:13-33
YAML Syntax
The YAML language support demonstrates a layered approach. A base source.yaml scope includes a specific version, source.yaml.1.2, by default. This allows for version-specific syntax rules.
{
"scopeName": "source.yaml",
"patterns": [
{
"comment": "Default to YAML version 1.2",
"begin": "\\A",
"while": "^",
"patterns": [
{
"include": "source.yaml.1.2"
}
]
}
]
}
Sources: extensions/yaml/syntaxes/yaml.tmLanguage.json:8-20
The same pattern is used for other languages like reStructuredText, which defines its grammar in rst.tmLanguage.json with a scope name of source.rst.
Sources: extensions/restructuredtext/syntaxes/rst.tmLanguage.json:6
Integration and Tooling
Code - OSS integrates with external tools and services through its extension model, enhancing developer workflows.
GitHub Integration
The github extension provides integration with GitHub repositories. It contributes commands for publishing repositories and opening files on GitHub or vscode.dev. It also adds menu items to the editor title, explorer context menu, and SCM view.
Sources: extensions/github/package.json:34-154
Authentication is handled by a separate github-authentication extension, which contributes authentication providers for GitHub and GitHub Enterprise Server. This separation of concerns allows other extensions to request GitHub authentication without managing credentials themselves.
Sources: extensions/github-authentication/package.json:29-45
Task Automation
Code - OSS supports task automation for build systems like Gulp and Make. Extensions can contribute taskDefinitions to allow the editor to auto-detect and run tasks from files like gulpfile.js.
The gulp extension activates onTaskType:gulp and defines a gulp task type that requires a task property.
{
"activationEvents": [ "onTaskType:gulp" ],
"contributes": {
"taskDefinitions": [
{
"type": "gulp",
"required": [ "task" ],
"properties": {
"task": {
"type": "string",
"description": "%gulp.taskDefinition.type.description%"
}
}
}
]
}
}
Sources: extensions/gulp/package.json:25-49
Dependency Management
To manage third-party components and their licenses, Code - OSS extensions use a cgmanifest.json file (Component Governance Manifest). This file lists all bundled third-party components, their repository source, version, and license. This is crucial for ensuring license compliance.
For example, the html-language-features extension declares its dependencies on js-beautify and data from the HTML 5.1 W3C Working Draft.
{
"registrations": [
{
"component": {
"type": "git",
"git": {
"name": "js-beautify",
"repositoryUrl": "https://github.com/beautify-web/js-beautify",
"commitHash": "12e73365f9d0b203843c5b7c22d7017845a7c580"
}
},
"license": "MIT",
"version": "1.6.8"
},
{
"component": {
"type": "other",
"other": {
"name": "HTML 5.1 W3C Working Draft",
"downloadUrl": "http://www.w3.org/TR/2015/WD-html51-20151008/",
"version": "08 October 2015"
}
},
"license": "W3C Document License"
}
]
}
Sources: extensions/html-language-features/cgmanifest.json:2-27
Conclusion
"Welcome to Code - OSS" provides a comprehensive development experience by building upon a powerful and flexible extension model. The project bundles a rich set of extensions that provide core language intelligence, syntax highlighting for a wide array of languages, and seamless integration with external tools like Git, GitHub, and various build systems. By understanding the contribution points and the structure of its extensions, developers can effectively customize and extend the editor to fit any workflow.