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
注册
onCommandActivation Event:onCommand:extension.helloWorld,so the extension becomes activated when user runs theHello Worldcommand.使用
contributes.commandsContribution Point 来让Hello World命令 在Command Palette 可用,并且绑定到命令idextension.helloWorld使用
commands.registerCommand的VS Code API绑定到已注册的命令IDextension.helloWorldActivation 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.jsonused to configure VS Code Debuggingtasks.jsonfor defining VS Code Taskstsconfig.jsonconsult the TypeScript Handbook
package.json
vsc使用 <publisher>.<name>作为一个插件的unique ID
tree-view
emmmmmm 看了一会代码 发现有文档 https://code.visualstudio.com/api/extension-guides/tree-view
直接看文档吧…