vscode svn插件

贡献点(Contribution Point)

参考: https://code.visualstudio.com/api/references/contribution-points

命令

package.json

	"contributes": {
		"commands": [
			{
				"command": "extension.hello",
				"title": "hello"
			}
		]
	}

extension.ts

commands.registerCommand('extension.hello', () => {
    window.showInformationMessage('Hello World!');
});

快捷键Ctrl + Shift + p 输入 hello
在这里插入图片描述

配置

package.json

	"contributes": {
		"configuration": {
			"title": "TypeScript configuration",
			"properties": {
				"typescript.useCodeSnippetsOnMethodSuggest": {
					"type": "boolean",
					"default": false,
					"description": "Complete functions with their parameter signature."
				},
				"typescript.tsdk": {
					"type": ["string", "null"],
					"default": null,
					"description": "Specifies the folder path containing the tsserver and lib*.d.ts files to use."
				}
			}
		}
	}

文件 - 首选项 - 设置
输入框输入TypeScript configuration
vscode svn插件_第1张图片
读取配置
extension.ts

const config = vscode.workspace.getConfiguration('typescript');
console.log(config.get('useCodeSnippetsOnMethodSuggest'));		// false

菜单

  • editor/title

package.json

	"contributes": {
		"commands": [
			{
				"command": "extension.menu_title",
				"title": "showSource",
				"icon": {
					"light": "./media/love_light.svg",
					"dark": "./media/love_dark.svg"
				}
			}
		],
		"menus": {
			"editor/title": [{
				"command": "extension.menu_title",
				"group": "navigation"
			}]
		}
	},

extension.ts

export function activate(context: vscode.ExtensionContext) {
	vscode.commands.registerCommand("extension.menu_title", () => {
		vscode.window.showInformationMessage('点击了爱心');
	});
}

vscode svn插件_第2张图片

  • commandPalette
"menus": {
    "commandPalette": [{
        "command": "extension.menu_title",
}]
"commands": [
	{
		"command": "extension.menu_title",
		"title": "showSource"
	}
],

vscode svn插件_第3张图片

  • explorer/context
    package.json
		"menus": {
			"explorer/context": [{
				"command": "extension.menu_title"
			}]
		}

vscode svn插件_第4张图片

  • editor/context
    package.json
		"menus": {
			"editor/context": [{
				"command": "extension.menu_title"
			}]
		}

vscode svn插件_第5张图片

  • editor/title/context
    vscode svn插件_第6张图片

  • debug/callstack/context
    vscode svn插件_第7张图片

  • debug/toolbar
    vscode svn插件_第8张图片

  • scm/title

vscode svn插件_第9张图片

  • scm/resourceGroup/context
    vscode svn插件_第10张图片

  • scm/resourceState/context
    vscode svn插件_第11张图片

  • scm/change/title
    vscode svn插件_第12张图片

  • view/title

		"viewsContainers": {
			"activitybar": [
			  {
				"id": "package-explorer",
				"title": "Package Explorer",
				"icon": "./media/dep.svg"
			  }
			]
		  },
		"views": {
			"package-explorer": [
			  {
				"id": "nodeDependencies",
				"name": "Node Dependencies"
			  }
			]
		  },
		"menus": {
			"view/title": [{
				"command": "view.menu_title",
				"group": "navigation"
			}],
			"view/item/context": [
				{
					"command": "view.menu_title",
					"group": "navigation"
				}
			]
		}
		"commands": [
			{
				"command": "view.menu_title",
				"title": "showSource",
				"icon": {
					"light": "./media/love_light.svg",
					"dark": "./media/love_dark.svg"
				}
			}
		]

extension.ts

export function activate(context: vscode.ExtensionContext) {
	const nodeDependenciesProvider = new DepNodeProvider(vscode.workspace.rootPath || '');
	vscode.window.registerTreeDataProvider('nodeDependencies', nodeDependenciesProvider);
	
	vscode.commands.registerCommand("view.menu_title", () => {
		vscode.window.showInformationMessage('点击了爱心');
	});
}

vscode svn插件_第13张图片
参考: https://code.visualstudio.com/api/extension-guides/tree-view

  • view/item/context
    vscode svn插件_第14张图片
    参考: https://code.visualstudio.com/api/extension-guides/tree-view

  • touchBar

  • comments/commentThread/title
    vscode svn插件_第15张图片

  • comments/commentThread/context

  • comments/comment/title

  • comments/comment/context

激活事件(activationEvents)

  • vscode启动后激活插件

package.json

	"activationEvents": [
		"*"
	],

extension.ts

export function activate(context: vscode.ExtensionContext) {
	console.log('插件激活');
}
  • 命令激活插件

package.json

	"activationEvents": [
		"onCommand:extension.hello"
	],

extension.ts

export function activate(context: vscode.ExtensionContext) {
	console.log('插件激活');
		vscode.commands.registerCommand("extension.hello", () => {
			vscode.window.showInformationMessage('Hello World');
		});
	});
}

你可能感兴趣的:(vscode)