VSCode 插件开发 第三课 语言服务器LSP
Extension Manifest 扩展清单文件
每个 Visual Studio Code 扩展都需要一个清单文件 package.json
位于扩展目录结构的根目录下。
Name | Required | Type | Details | |
---|---|---|---|---|
name | Y | string | The name of the extension - should be all lowercase with no spaces. ==扩展名 - 应全部为小写,无空格。== The name must be unique to the Marketplace. ==该名称对于 Marketplace 必须是唯一的。== | |
version | Y | string | SemVer compatible version. ==SemVer 兼容版本。语义化版本== ==版本格式:主版本号.次版本号.修订号,版本号递增规则如下:== ==1. 主版本号:当你做了不兼容的 API 修改,== ==2. 次版本号:当你做了向下兼容的功能性新增,== ==3. 修订号:当你做了向下兼容的问题修正。== ==先行版本号及版本编译信息可以加到“主版本号.次版本号.修订号”的后面,作为延伸。== | |
publisher | Y | string | The publisher identifier 出版商标识符 | |
engines | Y | object | An object containing at least the vscode key matching the versions of VS Code that the extension is compatible with. Cannot be * . For example: ^0.10.5 indicates compatibility with a minimum VS Code version of 0.10.5 .==至少包含与扩展兼容的 VS Code 版本的 vscode 键的对象。不能为 * 。例如:^0.10.5 表示与最低 VS Code 版本 0.10.5 兼容。== | |
license | string | Refer to npm's documentation. If you do have a LICENSE file in the root of your extension, the value for license should be "SEE LICENSE IN <filename>" .请参阅 npm 的文档 。如果扩展的根目录中确实有 LICENSE 文件, 则 license 的值应为 “SEE LICENSE IN <filename>”。 | ||
displayName | string | The display name for the extension used in the Marketplace. Marketplace 中使用的扩展的显示名称。 The display name must be unique to the Marketplace. 显示名称对于 Marketplace 必须是唯一的。 | ||
description | string | A short description of what your extension is and does. 扩展是什么和做什么的简短描述。 | ||
categories | string[] | The categories you want to use for the extensions. Allowed values: [Programming Languages, Snippets, Linters, Themes, Debuggers, Formatters, Keymaps, SCM Providers, Other, Extension Packs, Language Packs, Data Science, Machine Learning, Visualization, Notebooks, Education, Testing] 要用于扩展的类别。允许的值: [Programming Languages, Snippets, Linters, Themes, Debuggers, Formatters, Keymaps, SCM Providers, Other, Extension Packs, Language Packs, Data Science, Machine Learning, Visualization, Notebooks, Education, Testing] | ||
keywords | array | An array of keywords to make it easier to find the extension. These are included with other extension Tags on the Marketplace. This list is currently limited to 5 keywords. 一个关键字数组,以便更轻松地找到扩展。这些包含在 Marketplace 上的其他扩展标记中。此列表目前限制为 5 个关键字。 | ||
galleryBanner | object | Helps format the Marketplace header to match your icon. See details below. 帮助设置 Marketplace 标头的格式以匹配您的图标。请参阅下面的详细信息。 | ||
preview | boolean | Sets the extension to be flagged as a Preview in the Marketplace. 将扩展设置为在 Marketplace 中标记为 Preview。 | ||
main | string | The entry point to your extension. ==扩展的入口点。== | ||
browser | string | The entry point to your Web extension. Web 扩展的入口点。 | ||
contributes | object | An object describing the extension's contributions. ==描述扩展贡献的对象。== | ||
activationEvents | array | An array of the activation events for this extension. ==此扩展的激活事件数组。== | ||
badges | array | Array of approved badges to display in the sidebar of the Marketplace's extension page. Each badge is an object containing 3 properties: url for the badge's image URL, href for the link users will follow when clicking the badge and description .要在 Marketplace 扩展页面的侧边栏中显示的已批准徽章数组。每个徽章都是一个包含 3 个属性的对象: url 表示徽章的图像 URL,href 表示用户单击徽章时将遵循的链接,以及描述 。 | ||
markdown | string | Controls the Markdown rendering engine used in the Marketplace. Either github (default) or standard .控制 Marketplace 中使用的 Markdown 渲染引擎。 github (默认) 或 standard 。 | ||
qna | marketplace (default), string , false | Controls the Q & A link in the Marketplace. Set to marketplace to enable the default Marketplace Q & A site. Set to a string to provide the URL of a custom Q & A site. Set to false to disable Q & A altogether.控制市场中的问答链接。设置为 市场 以启用默认的市场问答网站。设置为字符串以提供自定义问答网站的 URL。设置为 false 将完全禁用 Q&A。 | ||
sponsor | object | Specify the location from where users can sponsor your extension. This is an object with a single property url , which links to a page where users can sponsor your extension.指定用户可以赞助您的扩展的位置。这是一个具有单个属性 url 的对象,该 url 链接到用户可以赞助扩展的页面。 | ||
dependencies | object | Any runtime Node.js dependencies your extensions needs. Exactly the same as npm's dependencies .扩展所需的任何运行时 Node.js 依赖项。与 npm 的 依赖项 完全相同。 | ||
devDependencies | object | Any development Node.js dependencies your extension needs. Exactly the same as npm's devDependencies .扩展所需的任何开发 Node.js 依赖项。与 npm 的 devDependencies 完全相同。 | ||
extensionPack | array | An array with the ids of extensions that can be installed together. The id of an extension is always ${publisher}.${name} . For example: vscode.csharp .一个数组,其中包含可以一起安装的扩展的 ID。扩展的 ID 始终为 ${publisher}.${name} 。例如:vscode.csharp 。 | ||
extensionDependencies | array | An array with the ids of extensions that this extension depends on. The id of an extension is always ${publisher}.${name} . For example: vscode.csharp .一个数组,其中包含此扩展所依赖的扩展的 ID。扩展的 ID 始终为 ${publisher}.${name} 。例如:vscode.csharp 。 | ||
extensionKind | array | An array that indicates where the extension should run in remote configurations. Values are ui (run locally), workspace (run on remote machine) or both, with the order setting the preference. For example: [ui, workspace] indicates the extension can run in either location but prefers to run on the local machine. See here for more details.一个数组,指示扩展应在远程配置中运行的位置。值为 ui (本地运行) 、 workspace (在远程计算机上运行) 或两者,顺序设置为首选项。例如:[ui, workspace] 表示扩展可以在任一位置运行,但更喜欢在本地计算机上运行。有关更多详细信息,请参阅此处 。 | ||
scripts | object | Exactly the same as npm's scripts but with extra VS Code specific fields such as vscode:prepublish or vscode:uninstall.与 npm 的 脚本 完全相同,但具有额外的 VS Code 特定字段,例如 vscode:prepublish 或 vscode:uninstall。 | ||
icon | string | The path to the icon of at least 128x128 pixels (256x256 for Retina screens). 图标的路径至少为 128x128 像素(对于 Retina 屏幕为 256x256)。 | ||
pricing | string | The pricing information for the extension. Allowed values: Free , Trial . Default: Free . See here for more details.扩展的定价信息。允许的值: Free 、 Trial 。默认值:Free 。有关更多详细信息,请参阅此处 。 | ||
capabilities | object | An object describing the extension's capabilities in limited workspaces: untrustedWorkspaces , virtualWorkspaces .描述扩展在有限工作区中的功能的对象: untrustedWorkspaces 、virtualWorkspaces 。 |
Also check npm's package.json
reference.
Contribution Points 描述扩展
贡献点 | Visual Studio Code 扩展 API --- Contribution Points | Visual Studio Code Extension API
contributes.configuration
提供将向用户公开的设置。用户将能够在 Settings (设置) 编辑器中或通过直接编辑 settings.json 文件来设置这些配置选项。
您的配置条目既可用于在 JSON 编辑器中编辑设置时提供智能感知,也可用于定义它们在设置 UI 中的显示方式。
NAME | TYPE | DESC | ||
---|---|---|---|---|
title | 标题 | 类别的标题 1️⃣️是用于该类别的标题。 | ||
properties | 配置 | 配置 对象中的 properties 2️⃣ 将形成一个字典,其中键是设置 ID,值提供有关设置的更多信息。尽管扩展可以包含多个类别的设置,但扩展的每个设置仍必须具有自己的唯一 ID。设置 ID 不能是另一个设置 ID 的完整前缀。 |