vscode使用

福尔摩斯对我笑 2019-05-30 56234 次 9864条

VSCODE配置项目,F5启动 npm

  • launch.json文件配置启动,打开谷歌或火狐浏览器
    {
      "version": "0.2.0",
      "configurations": [
        {
          "type": "chrome",
          "request": "launch",
          "name": "Launch Chrome",
          "url": "http://localhost:9528",
          "webRoot": "${workspaceFolder}/src",
          "breakOnLoad": true,
          "sourceMapPathOverrides": {
            "webpack:///./src/*": "${webRoot}/*"
          }
        },
        {
          "type": "firefox",
          "request": "launch",
          "name": "HCS: firefox",
          "url": "http://localhost:9528",
          "webRoot": "${workspaceFolder}/src",
          "preLaunchTask": "RunNode",
          "pathMappings": [{ "url": "webpack:///src/", "path": "${webRoot}/" }]
        }
      ]
    }
    
  • preLaunchTask是用来启动npm的,新建一个文件task.json,文件名名字不能改
    {
        "version": "2.0.0",
        "tasks": [
          {
            "label": "RunNode",
            "type": "npm",
            "script": "dev",
            "problemMatcher": []
          }
        ]
    }
    
    • F5启动即可

VSCODE插件开发

  • package.json常用配置
{
	// 插件的名字,应全部小写,不能有空格
	"name": "vscode-plugin-demo",
	// 插件的友好显示名称,用于显示在应用市场,支持中文
	"displayName": "VSCode插件demo",
	// 描述
	"description": "VSCode插件demo集锦",
	// 关键字,用于应用市场搜索
	"keywords": ["vscode", "plugin", "demo"],
	// 版本号
	"version": "1.0.0",
	// 发布者,如果要发布到应用市场的话,这个名字必须与发布者一致
	"publisher": "sxei",
	// 表示插件最低支持的vscode版本
	"engines": {
		"vscode": "^1.27.0"
	},
	// 插件应用市场分类,可选值: [Programming Languages, Snippets, Linters, Themes, Debuggers, Formatters, Keymaps, SCM Providers, Other, Extension Packs, Language Packs]
	"categories": [
		"Other"
	],
	// 插件图标,至少128x128像素
	"icon": "images/icon.png",
	// 扩展的激活事件数组,可以被哪些事件激活扩展,后文有详细介绍
	"activationEvents": [
		"onCommand:extension.sayHello"
	],
	// 插件的主入口
	"main": "./src/extension",
	// 贡献点,整个插件最重要最多的配置项
	"contributes": {
		// 插件配置项
		"configuration": {
			"type": "object",
			// 配置项标题,会显示在vscode的设置页
			"title": "vscode-plugin-demo",
			"properties": {
				// 这里我随便写了2个设置,配置你的昵称
				"vscodePluginDemo.yourName": {
					"type": "string",
					"default": "guest",
					"description": "你的名字"
				},
				// 是否在启动时显示提示
				"vscodePluginDemo.showTip": {
					"type": "boolean",
					"default": true,
					"description": "是否在每次启动时显示欢迎提示!"
				}
			}
		},
		// 命令
		"commands": [
			{
				"command": "extension.sayHello",
				"title": "Hello World"
			}
		],
		// 快捷键绑定
		"keybindings": [
			{
				"command": "extension.sayHello",
				"key": "ctrl+f10",
				"mac": "cmd+f10",
				"when": "editorTextFocus"
			}
		],
		// 菜单
		"menus": {
			// 编辑器右键菜单
			"editor/context": [
				{
					// 表示只有编辑器具有焦点时才会在菜单中出现
					"when": "editorFocus",
					"command": "extension.sayHello",
					// navigation是一个永远置顶的分组,后面的@6是人工进行组内排序
					"group": "navigation@6"
				},
				{
					"when": "editorFocus",
					"command": "extension.demo.getCurrentFilePath",
					"group": "navigation@5"
				},
				{
					// 只有编辑器具有焦点,并且打开的是JS文件才会出现
					"when": "editorFocus && resourceLangId == javascript",
					"command": "extension.demo.testMenuShow",
					"group": "z_commands"
				},
				{
					"command": "extension.demo.openWebview",
					"group": "navigation"
				}
			],
			// 编辑器右上角图标,不配置图片就显示文字
			"editor/title": [
				{
					"when": "editorFocus && resourceLangId == javascript",
					"command": "extension.demo.testMenuShow",
					"group": "navigation"
				}
			],
			// 编辑器标题右键菜单
			"editor/title/context": [
				{
					"when": "resourceLangId == javascript",
					"command": "extension.demo.testMenuShow",
					"group": "navigation"
				}
			],
			// 资源管理器右键菜单
			"explorer/context": [
				{
					"command": "extension.demo.getCurrentFilePath",
					"group": "navigation"
				},
				{
					"command": "extension.demo.openWebview",
					"group": "navigation"
				}
			]
		},
		// 代码片段
		"snippets": [
			{
				"language": "javascript",
				"path": "./snippets/javascript.json"
			},
			{
				"language": "html",
				"path": "./snippets/html.json"
			}
		],
		// 自定义新的activitybar图标,也就是左侧侧边栏大的图标
		"viewsContainers": {
			"activitybar": [
				{
					"id": "beautifulGirl",
					"title": "美女",
					"icon": "images/beautifulGirl.svg"
				}
			]
		},
		// 自定义侧边栏内view的实现
		"views": {
			// 和 viewsContainers 的id对应
			"beautifulGirl": [
				{
					"id": "beautifulGirl1",
					"name": "国内美女"
				},
				{
					"id": "beautifulGirl2",
					"name": "国外美女"
				},
				{
					"id": "beautifulGirl3",
					"name": "人妖"
				}
			]
		},
		// 图标主题
		"iconThemes": [
			{
				"id": "testIconTheme",
				"label": "测试图标主题",
				"path": "./theme/icon-theme.json"
			}
		]
	},
	// 同 npm scripts
	"scripts": {
		"postinstall": "node ./node_modules/vscode/bin/install",
		"test": "node ./node_modules/vscode/bin/test"
	},
	// 开发依赖
	"devDependencies": {
		"typescript": "^2.6.1",
		"vscode": "^1.1.6",
		"eslint": "^4.11.0",
		"@types/node": "^7.0.43",
		"@types/mocha": "^2.2.42"
	},
	// 后面这几个应该不用介绍了
	"license": "SEE LICENSE IN LICENSE.txt",
	"bugs": {
		"url": "https://github.com/sxei/vscode-plugin-demo/issues"
	},
	"repository": {
		"type": "git",
		"url": "https://github.com/sxei/vscode-plugin-demo"
	},
	// 主页
	"homepage": "https://github.com/sxei/vscode-plugin-demo/blob/master/README.md"
}

  • 编辑器命令

context.subscriptions.push(vscode.commands.registerTextEditorCommand('extension.testEditorCommand', (textEditor, edit) => {
console.log('您正在执行编辑器命令!');
console.log(textEditor, edit);
}));


  • 获取所有命令

vscode.commands.getCommands().then(allCommands => {
console.log('所有命令:', allCommands);
});
  • 通知
vscode.window.setStatusBarMessage('你好,前端艺术家!');

标签: 无

非特殊说明,本博所有文章均为博主原创。

头像也是LOGO
未来博客 博主大人
到了这个年纪,不应该再彷徨!

发表评论



 


已有 9864 条评论 1


  1. nike air max 97

    My spouse and i were absolutely more than happy Ervin managed to carry out his preliminary research while using the precious recommendations he got out of your web site. It’s not at all simplistic to just find yourself giving away hints that many most people may have been making money from. And we also grasp we have you to thank for that. The most important illustrations you have made, the easy site menu, the friendships you will aid to create – it’s mostly overwhelming, and it’s letting our son in addition to us reason why the idea is excellent, and that’s incredibly mandatory. Thanks for all the pieces!

    回复 2019年10月28日
  2. jordan 12

    Thank you for each of your work on this website. Gloria takes pleasure in participating in internet research and it’s obvious why. All of us hear all of the lively method you make great tactics via the web blog and as well strongly encourage response from other ones on this concern plus my daughter is in fact understanding so much. Take advantage of the rest of the new year. You have been performing a wonderful job.

    回复 2019年10月28日
  3. supreme clothing

    I am glad for commenting to let you be aware of of the terrific experience our daughter experienced visiting your webblog. She mastered too many things, including what it’s like to have a wonderful teaching character to have other people without hassle fully grasp various hard to do issues. You undoubtedly surpassed visitors’ desires. Many thanks for displaying those good, dependable, edifying and even easy tips about this topic to Sandra.

    回复 2019年10月27日
  4. jordans

    My husband and i were thrilled John managed to finish up his basic research with the precious recommendations he gained through your weblog. It is now and again perplexing to simply happen to be freely giving hints which men and women might have been making money from. We really know we have got the blog owner to be grateful to for that. All the illustrations you have made, the easy site navigation, the relationships you will aid to foster – it is mostly overwhelming, and it’s really facilitating our son and our family know that the subject matter is thrilling, and that’s exceptionally essential. Thank you for all!

    回复 2019年10月27日
  5. curry 4 shoes

    I intended to write you a little bit of remark to finally say thank you as before about the exceptional concepts you have provided here. It is quite surprisingly generous of you to convey openly exactly what a few individuals would’ve sold as an e book to make some profit for their own end, precisely seeing that you might have done it if you decided. These solutions also served as the easy way to realize that the rest have similar eagerness the same as my personal own to know a whole lot more on the topic of this problem. I think there are several more enjoyable occasions ahead for folks who examine your blog.

    回复 2019年10月27日
  6. air jordan

    I simply desired to thank you very much once more. I am not sure what I could possibly have done without the actual strategies revealed by you regarding this problem. Certainly was an absolute alarming circumstance in my circumstances, but coming across the expert way you treated that made me to jump for joy. Now i’m thankful for your support and in addition hope you really know what a great job that you’re doing teaching the mediocre ones through the use of your websites. Most likely you haven’t come across all of us.

    回复 2019年10月27日
  7. off white nike

    I wanted to write down a brief message to thank you for all of the nice guidelines you are posting here. My time consuming internet research has at the end of the day been paid with high-quality facts and techniques to write about with my visitors. I ‘d suppose that we site visitors are very fortunate to exist in a remarkable place with so many perfect individuals with useful strategies. I feel rather lucky to have encountered the web site and look forward to many more exciting times reading here. Thanks a lot once more for everything.

    回复 2019年10月26日
  8. kobe shoes

    Thank you for all your valuable effort on this website. My mum take interest in engaging in internet research and it’s obvious why. Most people know all regarding the lively ways you provide functional tricks via this web site and improve contribution from people on the situation plus our favorite child is really starting to learn a lot. Have fun with the remaining portion of the new year. You are always carrying out a stunning job.

    回复 2019年10月26日
  9. kd shoes

    I would like to show some appreciation to you just for rescuing me from such a issue. As a result of researching through the online world and getting strategies that were not powerful, I thought my entire life was done. Living devoid of the answers to the problems you’ve fixed as a result of your good write-up is a crucial case, as well as the ones which might have adversely affected my career if I had not noticed your site. Your primary mastery and kindness in dealing with all areas was excellent. I am not sure what I would’ve done if I had not come upon such a step like this. I’m able to at this time look forward to my future. Thanks very much for this high quality and result oriented help. I will not hesitate to propose the blog to anybody who would need direction on this situation.

    回复 2019年10月26日
  10. westbrook shoes

    Thank you a lot for providing individuals with a very remarkable possiblity to read from this website. It is always very excellent and as well , stuffed with a lot of fun for me and my office mates to search your site more than thrice a week to learn the fresh stuff you have got. Not to mention, I’m just actually astounded considering the surprising strategies you give. Certain two facts in this article are unquestionably the very best I’ve had.

    回复 2019年10月25日
  11. mbt shoes

    I precisely needed to thank you very much yet again. I do not know what I would have handled in the absence of these recommendations revealed by you concerning such situation. It was actually a real hard matter in my opinion, but considering the very expert avenue you dealt with the issue made me to leap over delight. I’m just thankful for the work as well as trust you comprehend what an amazing job you are always getting into teaching others thru your website. More than likely you haven’t come across any of us.

    回复 2019年10月25日
  12. adidas gazelle

    Thanks a lot for giving everyone an exceptionally pleasant possiblity to check tips from here. It is always very brilliant and also stuffed with fun for me personally and my office fellow workers to search your website really three times in 7 days to read the new items you will have. And definitely, I am also at all times impressed considering the eye-popping things you serve. Some 3 tips in this article are unquestionably the simplest I’ve ever had.

    回复 2019年10月25日
  13. moncler jacket

    I precisely needed to appreciate you again. I do not know the things that I might have gone through without these strategies revealed by you directly on such a area. This was a real frustrating matter for me, but encountering your professional fashion you dealt with the issue made me to cry over happiness. Extremely happier for the assistance and then have high hopes you realize what a powerful job you are providing educating others via your web blog. I am sure you haven’t encountered any of us.

    回复 2019年10月24日
  14. kd shoes

    I simply wanted to say thanks all over again. I do not know what I might have tried in the absence of those solutions provided by you regarding this field. This has been a alarming difficulty in my position, nevertheless considering a new professional tactic you treated it forced me to jump over gladness. I will be happy for your guidance and even sincerely hope you find out what a great job that you are carrying out educating people today via your webblog. More than likely you’ve never met all of us.

    回复 2019年10月24日
  15. coach factory outlet

    I am glad for commenting to let you be aware of of the wonderful experience my child had going through yuor web blog. She picked up lots of pieces, most notably what it is like to have an excellent coaching nature to have certain people without difficulty grasp specified advanced topics. You actually surpassed people’s expected results. Thank you for providing the productive, trusted, edifying and even easy thoughts on that topic to Mary.

    回复 2019年10月24日
  16. nike cortez men

    My wife and i have been absolutely thankful Edward managed to finish off his reports by way of the ideas he made while using the web site. It is now and again perplexing to just continually be giving for free hints which usually people may have been trying to sell. Therefore we grasp we now have you to thank for this. The main explanations you’ve made, the straightforward site menu, the friendships your site give support to foster – it’s everything unbelievable, and it is making our son and us recognize that the topic is fun, and that’s tremendously vital. Many thanks for all the pieces!

    回复 2019年10月24日
  17. nike air max 2017

    I’m also writing to make you be aware of of the impressive experience my cousin’s daughter found visiting your web site. She came to find so many issues, most notably what it’s like to possess an amazing helping mindset to get others quite simply fully understand various grueling things. You undoubtedly exceeded visitors’ desires. Thank you for supplying such invaluable, trustworthy, informative and as well as cool tips about this topic to Gloria.

    回复 2019年10月23日
  18. jordan shoes

    Thanks for all of the work on this blog. My mum really likes conducting investigation and it is obvious why. We know all relating to the compelling mode you convey powerful suggestions via this website and even strongly encourage response from website visitors about this matter so my daughter is always studying a whole lot. Have fun with the rest of the year. You’re the one performing a powerful job.

    回复 2019年10月23日
  19. nhl jerseys

    Thanks so much for providing individuals with an extraordinarily spectacular opportunity to read in detail from this blog. It’s always very fantastic and also full of fun for me personally and my office colleagues to visit the blog not less than 3 times in one week to read through the latest issues you will have. And lastly, I am also always satisfied for the splendid advice you serve. Some 1 facts in this posting are in fact the most beneficial I’ve ever had.

    回复 2019年10月22日
  20. yeezy shoes

    I wanted to put you a very little remark so as to give many thanks as before for all the fantastic tips you have shared here. This is quite remarkably open-handed with you to provide openly all many individuals would’ve made available as an e-book to get some profit for their own end, precisely given that you might well have done it in the event you wanted. Those smart ideas in addition worked like the fantastic way to fully grasp other people online have the identical dreams much like my personal own to realize a whole lot more when considering this problem. Certainly there are millions of more pleasant instances ahead for individuals that looked at your site.

    回复 2019年10月21日
  21. fitflop sale

    I would like to show appreciation to this writer just for rescuing me from this particular situation. Right after surfing around through the world wide web and obtaining ideas which are not helpful, I thought my entire life was done. Being alive minus the solutions to the difficulties you’ve fixed through this guideline is a crucial case, as well as the kind which might have negatively affected my career if I had not discovered your site. Your good skills and kindness in touching a lot of stuff was useful. I am not sure what I would have done if I hadn’t discovered such a stuff like this. I can at this time look forward to my future. Thank you very much for this high quality and amazing help. I won’t hesitate to endorse your blog to anyone who ought to have counselling on this matter.

    回复 2019年10月20日
  22. ultra boost

    Thanks a lot for providing individuals with an exceptionally breathtaking chance to discover important secrets from this site. It’s always very lovely and as well , stuffed with fun for me and my office co-workers to visit your blog the equivalent of 3 times per week to study the fresh guidance you have got. Of course, I am at all times pleased considering the gorgeous solutions you serve. Selected 1 points in this article are in reality the finest I’ve ever had.

    回复 2019年10月19日
  23. ferragamo belt

    My husband and i were so thrilled when John could round up his basic research while using the ideas he grabbed out of your blog. It’s not at all simplistic just to happen to be giving away tips and hints which people today could have been selling. And we all see we’ve got you to appreciate for that. The type of illustrations you have made, the simple site navigation, the friendships you can make it easier to engender – it’s got most astounding, and it’s really letting our son in addition to our family recognize that the theme is excellent, and that’s pretty vital. Many thanks for all!

    回复 2019年10月18日
  24. fila shoes

    Thank you so much for providing individuals with remarkably special possiblity to read in detail from this blog. It’s usually so beneficial plus full of a great time for me personally and my office mates to visit your site particularly three times in one week to study the fresh secrets you have. Of course, I’m so usually amazed with your very good ideas you give. Certain 2 areas on this page are basically the most impressive we’ve had.

    回复 2019年10月17日
  25. StevDede

    Buy Avanafil Online Propecia 5 Mg Effetti Collaterali Zithromax Solubility buy viagra online Propecia Monthly Budget Can You Treat Chlamydia With Flagyl 200 Vrai Viagra Pas Cher

    回复 2019年10月17日
  26. ferragamo belts

    I actually wanted to make a note so as to thank you for all the nice advice you are sharing on this site. My time consuming internet research has now been rewarded with awesome ideas to write about with my friends and classmates. I ‘d state that that we website visitors actually are really blessed to exist in a fine website with very many perfect people with valuable solutions. I feel extremely lucky to have used your entire website page and look forward to so many more entertaining minutes reading here. Thanks once again for all the details.

    回复 2019年10月16日
  27. yeezy boost

    I simply needed to thank you so much once more. I’m not certain the things that I would’ve implemented in the absence of the type of aspects shown by you over my situation. It was actually a very terrifying problem for me, but understanding your expert technique you dealt with the issue forced me to weep with happiness. Now i am thankful for the help as well as believe you really know what a powerful job you were carrying out instructing the others via your blog post. I am sure you’ve never come across any of us.

    回复 2019年10月15日
  28. reebok outlet

    My spouse and i were excited Chris managed to deal with his analysis because of the ideas he gained using your site. It’s not at all simplistic to just always be giving for free tips and tricks which often others could have been trying to sell. Therefore we grasp we’ve got the website owner to thank for this. These explanations you’ve made, the simple site navigation, the friendships you can help instill – it is many wonderful, and it’s aiding our son and us know that that idea is excellent, which is certainly pretty vital. Many thanks for everything!

    回复 2019年10月14日
  29. cheap nba jerseys

    My wife and i have been really peaceful when Chris could conclude his reports because of the ideas he gained from your very own web pages. It is now and again perplexing to simply happen to be giving for free secrets and techniques which usually some others might have been selling. And we grasp we now have the blog owner to thank because of that. The most important illustrations you made, the simple web site menu, the friendships you can aid to foster – it’s everything overwhelming, and it is letting our son and the family do think that subject matter is awesome, which is certainly especially fundamental. Thanks for the whole thing!

    回复 2019年10月13日
  30. christian louboutin outlet

    My husband and i have been lucky that Michael managed to do his studies through the entire precious recommendations he discovered from your own site. It’s not at all simplistic just to choose to be giving freely solutions which the others might have been selling. Therefore we discover we’ve got the blog owner to thank for that. The main explanations you have made, the simple blog menu, the relationships you make it easier to promote – it’s many awesome, and it is assisting our son in addition to us do think that matter is pleasurable, which is wonderfully vital. Many thanks for the whole thing!

    回复 2019年10月12日
  31. kyrie 5 shoes

    I together with my friends were found to be going through the good guidelines from your web blog then immediately came up with a terrible feeling I never expressed respect to the website owner for those secrets. These guys came as a result passionate to learn them and now have truly been taking advantage of those things. I appreciate you for getting really considerate and for pick out these kinds of fabulous information millions of individuals are really desirous to learn about. My very own honest apologies for not expressing appreciation to earlier.

    回复 2019年10月11日
  32. converse outlet

    I want to express my gratitude for your kind-heartedness in support of men and women who absolutely need help with that concept. Your personal dedication to getting the solution across became remarkably interesting and has specifically allowed guys and women much like me to reach their pursuits. The interesting tips and hints implies a whole lot to me and extremely more to my colleagues. Regards; from each one of us.

    回复 2019年10月10日
  33. yeezy boost 350

    Thank you a lot for giving everyone an extremely nice possiblity to discover important secrets from this website. It can be very fantastic and as well , full of a good time for me and my office colleagues to search your website at the very least three times a week to read through the new items you have. And definitely, I’m so always amazed concerning the astonishing things served by you. Certain 1 points in this posting are undeniably the finest we have ever had.

    回复 2019年10月9日
  34. birkin bag

    Thank you so much for giving everyone an exceptionally splendid possiblity to read articles and blog posts from this site. It’s always so beneficial and jam-packed with a good time for me personally and my office acquaintances to visit your site more than three times per week to see the newest stuff you will have. And definitely, I am just certainly amazed considering the superb tactics you serve. Some two facts in this article are rather the most suitable I have had.

    回复 2019年10月8日
  35. fila shoes

    I am glad for commenting to make you know of the superb discovery our child developed using your site. She came to find plenty of details, not to mention what it’s like to have an awesome helping mindset to have many more without difficulty have an understanding of certain impossible issues. You actually did more than people’s expectations. Thanks for producing these precious, healthy, revealing as well as unique tips on that topic to Lizeth.

    回复 2019年10月7日