vsc extension 入门尝试
开始 & 安装
文档
https://code.visualstudio.com/api/get-started/your-first-extension
https://github.com/microsoft/vscode-extension-samples
install & Run
1 | npm install -g yo generator-code |
选择你希望的选项
code ./新建目录
按F5
启动
按Ctrl+Shift+P
输入Hello world
回车
当你修改了代码后,在新打开的窗口Ctrl+Shift+P
再输入Reload Window
就重新加载了代码
解剖
看package.json
注册
onCommand
Activation Event:onCommand:extension.helloWorld
,so the extension becomes activated when user runs theHello World
command.使用
contributes.commands
Contribution Point 来让Hello World
命令 在Command Palette 可用,并且绑定到命令idextension.helloWorld
使用
commands.registerCommand
的VS Code API绑定到已注册的命令IDextension.helloWorld
Activation Events: events upon which your extension becomes active.
Contribution Points: static declarations that you make in the package.json Extension Manifest to extend VS Code.
VS Code API: 代码中API,可以在你的extension代码中调起
其它配置文件
launch.json
used to configure VS Code Debuggingtasks.json
for defining VS Code Taskstsconfig.json
consult the TypeScript Handbook
package.json
vsc使用 <publisher>.<name>
作为一个插件的unique ID
tree-view
emmmmmm 看了一会代码 发现有文档 https://code.visualstudio.com/api/extension-guides/tree-view
直接看文档吧…