vscode使用

福尔摩斯对我笑 2019-05-30 7527 次 2167条

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
未来博客 博主大人
到了这个年纪,不应该再彷徨!

发表评论



 


已有 2167 条评论 1


  1. jasa pengurusan siujk

    Great info. Lucky me I ran across your site by chance (stumbleupon). I’ve saved it for later!

    回复 2020年2月26日
  2. SEO Baltimore

    Greetings! Very useful advice within this article! It is the little changes that produce the biggest changes. Thanks for sharing!

    回复 2020年2月26日
  3. ass hole

    Hi, I do believe this is an excellent blog. I stumbledupon it 😉 I’m going to come back yet again since i have book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to help others.

    回复 2020年2月26日
  4. cialis prescription

    tadalafil (cialis) for bph [url=http://buyscialisrx.com/]buy cialis online[/url] tadalafil antibiotics cialis
    no prescription herbs containing tadalafil cialis
    tadalafil generika http://buyscialisrx.com/ tadalafil bioequivalencia

    回复 2020年2月26日
  5. piss off

    You’ve made some good points there. I checked on the net for more information about the issue and found most individuals will go along with your views on this site.

    回复 2020年2月26日
  6. http://www.tabletopperslinen.com/ActivityFeed/MyProfile/tabid/61/UserId/44859/Default.aspx

    Hey there are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and create my own. Do you require any html coding expertise to
    make your own blog? Any help would be greatly appreciated!

    回复 2020年2月26日
  7. ﹝카지노사이트﹞■-아바타게임-►바카라 돈 따는 법✏『』☄〈akaxx.com〉배터리바둑이주소➶무료 포커 게임►[]2019-02-27-01-48[]✣♜ヌSN

    An interesting discussion is worth comment. There’s no doubt that that you ought to write more about this topic, it may not be a taboo subject but usually people do not talk about such topics. To the next! All the best!!

    回复 2020年2月26日
  8. 카지노사이트

    This is new India. Veterans in different Avatars!! https://www.trade21forum.com/index.php?topic=138978.0

    回复 2020年2月26日
  9. lexus888 versi Mobile

    Nice post. I learn something totally new and challenging on blogs I
    stumbleupon on a daily basis. It’s always helpful to read through
    articles from other writers and use something from
    their web sites.

    回复 2020年2月26日
  10. cum on teen ass

    Our Gay Cams are super addictive and will get you hooked from the moment you start using them.
    Visit his gay live chat room and see what’s in store for you.

    In modern times, chatting and chat rooms have become an essential part of life.
    The second issue is that families already have media control.
    That’s the first issue. Porn, sex with strangers has temporary rush and gratification, but it does not make you “happy”.
    If you were never affected by porn, sex with your loved partner would
    be different, because you see her for the lovely kind and beautiful
    human being she is, not an object for your pleasure.
    Drama: Their wedding certainly made headlines, with Jules (left) having dumped her best pal and former MAFS
    co-star Melissa Lucarelli (right) from being her bridesmaid.
    You also need to know the right platform
    for your live stream. A private sex chat or also known as
    cam to cam chat is when you enable your own webcam
    stream so that the sex model can see you masturbate as well.
    Video Chat LIVE with experts or enjoy a live sex chat at the world’s largest webcam arena!
    Breasts from the soft couple fucking on webcam.

    回复 2020年2月26日
  11. date

    After going over a number of the articles on your website, I seriously appreciate your technique of writing a blog. I saved as a favorite it to my bookmark site list and will be checking back soon. Please check out my web site too and tell me what you think.

    回复 2020年2月26日
  12. porno

    Greetings! Very helpful advice within this article! It’s the little changes that make the largest changes. Thanks a lot for sharing!

    回复 2020年2月26日
  13. assshole

    I quite like reading through a post that can make people think. Also, thanks for allowing me to comment!

    回复 2020年2月26日
  14. boong

    Hello, I think your web site might be having web browser compatibility problems. When I look at your blog in Safari, it looks fine however, when opening in Internet Explorer, it has some overlapping issues. I simply wanted to provide you with a quick heads up! Other than that, great blog!

    回复 2020年2月26日
  15. Cheap towing

    Greetings! Very helpful advice in this particular article! It’s the little changes that produce
    the most significant changes. Thanks for sharing!

    回复 2020年2月26日
  16. w88

    I’m gone to tell my little brother, that he should also pay a visit this weblog on regular basis to
    obtain updated from latest gossip.

    回复 2020年2月26日
  17. anal

    Saved as a favorite, I like your website!

    回复 2020年2月26日
  18. erotic

    There’s definately a lot to learn about this subject. I love all of the points you made.

    回复 2020年2月26日
  19. escort

    Pretty! This has been a really wonderful post. Many thanks for supplying this info.

    回复 2020年2月26日
  20. yeezy

    I enjoy you because of each of your efforts on this web site. Gloria really loves conducting investigations and it’s obvious why. My partner and i know all regarding the lively medium you produce useful tips and hints on this web site and in addition increase contribution from visitors on this issue then our favorite child is without question starting to learn a whole lot. Enjoy the remaining portion of the year. You have been performing a pretty cool job.

    回复 2020年2月26日
  21. Abbruch aus Lübeck

    After going over a handful of the blog articles on your site, I seriously like your technique of blogging. I saved as a favorite it to my bookmark webpage list and will be checking back in the near future. Please check out my web site too and let me know what you think.

    回复 2020年2月26日
  22. cocksuck

    This is the perfect webpage for anybody who hopes to understand this topic. You realize a whole lot its almost tough to argue with you (not that I personally will need to…HaHa). You definitely put a fresh spin on a topic which has been discussed for decades. Excellent stuff, just great!

    回复 2020年2月26日
  23. erection

    I enjoy looking through a post that will make men and women think. Also, many thanks for allowing for me to comment!

    回复 2020年2月26日
  24. Rain Go Gutters Raleigh

    I couldn’t refrain from commenting. Exceptionally well written.

    回复 2020年2月26日
  25. xxx mom yoga

    I was very pleased to discover this website. I need to to thank you
    for ones time for this fantastic read!! I definitely really liked every little
    bit of it and I have you saved as a favorite to check out new things in your blog.

    回复 2020年2月26日
  26. แทงหวย

    Remarkable issues here. I am very happy to look your article.
    Thank you a lot and I am looking ahead to contact you.
    Will you kindly drop me a e-mail?

    回复 2020年2月26日
  27. 188bet

    Hi there just wanted to give you a quick heads up and let you know
    a few of the images aren’t loading correctly. I’m not sure why but I
    think its a linking issue. I’ve tried it in two
    different web browsers and both show the same results.

    回复 2020年2月26日
  28. Kimcycle 回复 2020年2月26日
  29. orgasm

    After looking over a few of the articles on your site, I seriously like your way of blogging. I saved it to my bookmark webpage list and will be checking back soon. Please check out my website as well and tell me what you think.

    回复 2020年2月26日
  30. 우리카지노

    From the Rose Bowl carry black runs Cataract, Spider and Ripsaw are open along with blue runs C-prime and Stone Creek Meadows.
    The Nastar course is ready for many who need some race motion! https://uricasino114.com

    回复 2020年2月26日
  31. 우리카지노

    From the Rose Bowl carry black runs Cataract, Spider and
    Ripsaw are open along with blue runs C-prime and Stone Creek Meadows.
    The Nastar course is ready for many who need some race motion! https://uricasino114.com

    回复 2020年2月26日
  32. bitch

    This site was… how do I say it? Relevant!! Finally I’ve found something that helped me. Kudos!

    回复 2020年2月26日
  33. sadist

    Way cool! Some extremely valid points! I appreciate you writing this article plus the rest of the site is also very good.

    回复 2020年2月26日
  34. socialvip.co.uk

    Hi, i believe that i noticed you visited my blog
    so i got here to go back the prefer?.I am trying to in finding issues to improve my website!I assume its ok to
    make use of some of your concepts!!

    回复 2020年2月26日
  35. a490 tension control bolts

    Hi! I just wanted to ask if you ever have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing months of hard work due to no backup. Do you have any methods to prevent hackers?

    回复 2020年2月26日
  36. Play Lotto

    Way cool! Some very valid points! I appreciate you penning this post and the rest of the site is really good.

    回复 2020年2月26日
  37. cream pemutih wajah yang aman

    An intriguing discussion is definitely worth comment. I think that you should write
    more on this issue, it may not be a taboo matter
    but usually folks don’t speak about these issues.
    To the next! Many thanks!!

    回复 2020年2月25日
  38. douche

    Excellent post. I definitely appreciate this site. Thanks!

    回复 2020年2月25日
  39. cbd öl kaufen schweiz

    Greetings! Very useful advice within this article!
    It’s the little changes that make the most important changes.
    Thanks for sharing!

    回复 2020年2月25日
  40. erotic

    After I originally left a comment I appear to have clicked on the -Notify me when new comments are added- checkbox and from now on every time a comment is added I receive four emails with the exact same comment. Perhaps there is an easy method you are able to remove me from that service? Many thanks!

    回复 2020年2月25日
  41. fuck

    I was excited to uncover this great site. I want to to thank you for your time due to this wonderful read!! I definitely really liked every bit of it and I have you bookmarked to see new information on your blog.

    回复 2020年2月25日
  42. website

    I really like your blog.. very nice colors & theme.
    Did you make this website yourself or did you hire someone to do
    it for you? Plz answer back as I’m looking to create my own blog
    and would like to know where u got this from. cheers

    回复 2020年2月25日
  43. mother in law sex

    Each week, Free for All brings you ideas, news, and reviews from
    the world of free-to-play, indie, and import games — a world that is often overlooked by gamers.
    She picks up the empty cooler that I had brought along for drinks and brings it to my
    doorstep. Do you know what she’d do if she were here right now,
    ” Laura asked softly?!? “No,” he gasped, “what would she
    do! I’m sure that she is, but if she were here right now, what would you do to her,” Laura asked teasingly!?! “I guess that I’d fuck her,” Peter replied, “I’d love to get on top and
    just ride her! Lovely teen sex its best porn teens
    love hardcore source. Why not,” Laura asked, “I’m sure if she ever saw your big cock she’s
    just fall in love with you! See, what did I tell you,” Lauren said softly, “just look
    at this incredible piece of cock flesh, so hard and soft both at
    the same time!

    回复 2020年2月25日
  44. Home Inspector Fayetteville NC

    Good post! We are linking to this great article on our site. Keep up the great writing.

    回复 2020年2月25日
  45. modern world construction

    Hey there! I realize this is sort of off-topic but I had to ask. Does building a well-established blog such as yours take a lot of work? I am brand new to running a blog but I do write in my journal everyday. I’d like to start a blog so I can easily share my experience and thoughts online. Please let me know if you have any kind of recommendations or tips for new aspiring bloggers. Appreciate it!

    回复 2020年2月25日