插件指南

通过Hello World学习过基本的VS Code插件API之后,现在是时间搞搞真正的插件了。在插件功能章节,在更宽泛的层面上介绍了插件能做些什么,本章则细化了各个功能点,并提供了详细的代码和VS Code API的解释。

在每个指南-示例组合中,你将会看到:

  • 贯穿整个代码的注释
  • 使用示例插件的gif或者图片
  • 运行示例插件指引
  • 使用过的VS Code API列表
  • 使用过的配置点列表
  • 真正的组合插件示例
  • API概念解释

指南和例子


下面是一份指南和例子的表格,虽然每个指南都要有示例代码,但是一些示例目前暂时还没有与之匹配的指南。

每个例子都至少阐释了一个VS Code API或者发布内容配置的使用。

例子 VS Code网页指南 API & 配置
Webview Sample /extension-guides/webview window.createWebviewPanel
window.registerWebviewPanelSerializer
Status Bar Sample N/A window.createStatusBarItem
StatusBarItem
Tree View Sample /extension-guides/tree-view window.createTreeView
window.registerTreeDataProvider
TreeView
TreeDataProvider
contributes.views
contributes.viewsContainers
Task Provider Sample /extension-guides/task-provider tasks.registerTaskProvider
Task
ShellExecution
contributes.taskDefinitions
Multi Root Sample N/A workspace.getWorkspaceFolder
workspace.onDidChangeWorkspaceFolders
Completion Provider Sample N/A languages.registerCompletionItemProvider
CompletionItem
SnippetString
File System Provider Sample N/A workspace.registerFileSystemProvider
Editor Decorator Sample N/A TextEditor.setDecorations
DecorationOptions
DecorationInstanceRenderOptions
ThemableDecorationInstanceRenderOptions
window.createTextEditorDecorationType
TextEditorDecorationType
contributes.colors
I18n Sample N/A
Terminal Sample N/A window.createTerminal
window.onDidChangeActiveTerminal
window.onDidCloseTerminal
window.onDidOpenTerminal
window.Terminal
window.terminals
Vim Sample N/A commands
StatusBarItem
window.createStatusBarItem
TextEditorCursorStyle
window.activeTextEditor
Position
Range
Selection
TextEditor
TextEditorRevealType
TextDocument

语言插件示例


下面的部分是语言插件相关示例:

例子 VS Code网页指南
Snippet Sample /language-extensions/snippet-guide contributes.snippets
Language Configuration Sample /language-extensions/language-configuration-guide contributes.languages
LSP Sample /language-extensions/language-server-extension-guide
LSP Log Streaming Sample N/A
LSP Multi Root Server Sample https://github.com/Microsoft/vscode/wiki/Adopting-Multi-Root-Workspace-APIs#language-client--language-server