2017-12-24 为新语言编写Visual Studio Code语法高亮插件
本文源码库: program-in-chinese/quan4-highlighter
语法高亮是一个开发环境的基本功能. 此文尝试为之前的"圈4"语言(详见编程语言试验之Antlr4+JavaScript实现"圈4")编写一个高亮插件, 仅为演示之用. 参考的是Visual Studio Code官方文档: Add Themes, Snippets and Colorizers to Visual Studio Code. 首先创建插件如下, 为".圈4"的源文件添加高亮:
$ yo code
_-----_ ╭──────────────────────────╮
| | │ Welcome to the Visual │
|--(o)--| │ Studio Code Extension │
`---------´ │ generator! │
( _´U`_ ) ╰──────────────────────────╯
/___A___\ /
| ~ |
__'.___.'__
´ ` |° ´ Y `
? What type of extension do you want to create? New Language Support
Enter the URL (http, https) or the file path of the tmLanguage grammar or press ENTER to start with a new grammar.
? URL or file to import, or none for new:
? What's the name of your extension? 圈4高亮
? What's the identifier of your extension? quan4-highlighter
? What's the description of your extension? 圈4语言的VS Code插件
? What's your publisher name (more info: https://code.visualstudio.com/docs/tools/vscecli#_publishing-extensions)? nobody
Enter the id of the language. The id is an identifier and is single, lower-case name such as 'php', 'javascript'
? Language id: quan4
Enter the name of the language. The name will be shown in the VS Code editor mode selector.
? Language name: 圈4
Enter the file extensions of the language. Use commas to separate multiple entries (e.g. .ruby, .rb)
? File extensions: .圈4
Enter the root scope name of the grammar (e.g. source.ruby)
? Scope names: source.圈4
create quan4-highlighter/syntaxes/quan4.tmLanguage.json
create quan4-highlighter/.vscode/launch.json
create quan4-highlighter/package.json
create quan4-highlighter/README.md
create quan4-highlighter/CHANGELOG.md
create quan4-highlighter/vsc-extension-quickstart.md
create quan4-highlighter/language-configuration.json
create quan4-highlighter/.vscodeignore
create quan4-highlighter/.gitignore
Your extension quan4-highlighter has been created!
默认语法文件syntaxes/quan4.tmLanguage.json中, 关键词的模式匹配为:
"match": "\\b(if|while|for|return)\\b"
直接改为:
"match": "求约数"
运行插件后(F5新运行, Command+R可以在插件修改后刷新)实现:
很明显它是最直接的正则表达式匹配. 还不确定是否能做到空格敏感, 以及语法检验.
这只是第一步, 之后还需对语法定义格式(TextMate Manual & Language Grammars)进行深入学习.
2017-12-24 为新语言编写Visual Studio Code语法高亮插件的更多相关文章
- 新成员!Visual Studio Code --跨平台的开发工具(支持OSX, Linux 和 Windows)
原文出处:新成员!Visual Studio Code --跨平台的开发工具(支持OSX, Linux 和 Windows) 这是我的文章备份 http://www.dotblogs.com.tw/ ...
- Visual studio code离线安装插件
Visual studio code离线安装插件 公司研发区不能连接公网,使用Visual studio code(vsc)写Golang代码需要安装Go插件,下面介绍下,vsc离线安装插件的步骤.以 ...
- 2017-12-04 编写Visual Studio Code插件初尝试
参考官方入门: Your First Visual Studio Code Extension - Hello World 源码在: program-in-chinese/vscode_helloWo ...
- Visual Studio Code 通过 Chrome插件Type Script断点调试Angular 2
1. 下载Visual Studio Code (https://code.visualstudio.com/) 2. 安装插件Debugger for chrome 3. 确定tsconfig.js ...
- Visual Studio Code IDE开发插件配置
[PHP通用集成环境] PHP Extension Pack #PHP拓展包,PHP开发最重要的拓展 PHP Intelephense #PHP自动补全工具 PHP IntelliSense #PHP ...
- Visual Studio Code 使用 Git插件报错 - Permission denied (publickey)
在使用GitHub的时候,为了避免每次输入用户名密码,都会使用SSH方式代替Https. 按网上教程,大多数使用SSH-KeyGen生成公私钥对,而后上传公钥至Github,并切换Repositori ...
- Visual Studio Code如何编写运行C、C++
Visual Studio Code如何编写运行C.C++ 作者:知乎用户链接:https://www.zhihu.com/question/30315894/answer/154979413来源:知 ...
- 在Visual Studio Code中开发Office Add-in
作者:陈希章 发表于 2017年7月13日 上一篇 我介绍了如何在Visual Studio中开发Office Add-in,因为有标准的项目模板,一系列配套的工具,尤其是自带的一键调试功能,可以让开 ...
- [翻译]使用Visual Studio Code怎样调试Rust
我将 Visual Studio Code 作为Rust首选编辑器.遗憾的是 VS Code 不能非常好地完成 Rust 的调试. 配置调试器不难,但仍然需要几个步骤.我已经完整配置了好几次.我正在写 ...
随机推荐
- 多个DbContext修改同一张表测试
多个DbContext修改同一张表经测试是可行的. UserStore和DepartmentStore都可以向SysLog表写入数据 用多个线程同时通过UserStore和DepartmentStor ...
- Bitmap对图像的处理
p { margin-bottom: 0.1in; line-height: 120% } a:link { } Bitmap对图像的处理 一.引言: 在开发中涉及到图片包括.png,.gif,.9. ...
- java.exe进程来源排查录
解决后的一个小结:此处是一个tomcat端口,这种情况下,可以先在浏览器访问下看看效果,就可以快速定位 又发现一个简单的办法: 下面的定位过程,适用于各种场合 无意中发现有个进程开了好多端口,很奇怪 ...
- jmeter简单的使用
jmeter简单的使用 一般步骤是:在测试计划下面新建一个线程组,线程组下面添加请求,请求中添加结果和断言 1.打开页面: 2.添加线程组: 3.线程组中设置参数: 很重要的几个参数:线程数.ramp ...
- 你不知道的JavaScript--Item14 使用prototype的几点注意事项
1.在prototype上保存方法 不使用prototype进行JavaScript的编码是完全可行的,例如: function User(name, passwordHash) { this.nam ...
- java之集合Collection详解之2
package cn.itcast_02; import java.util.ArrayList; import java.util.Collection; /* * 练习:用集合存储5个学生对象,并 ...
- 吐槽一下--最近多次在腾讯以及万科的面试经历---Web前端与PHP后端开发
前端时间,由于职业发展等,想要换一份工作,于是投递了一些国内还算知名的公司,列如: 腾讯.万科之类的: (1)首先说一下这两家公司的反馈情况: 腾讯:投递到反馈,(初次人事打电话沟通)大约1周,三次不 ...
- Java 读书笔记 (十五) Java 异常处理
捕获异常 使用try 和catch关键字可以捕获异常.try/catch 代码块放在异常可能发生的地方. try/catch 代码块中的代码称为保护代码 ,使用try/catch的语法如下: try ...
- conn.go 源码阅读
), Conn: conn, } return k, v } // 返回远程节点地址 func (self *Connect) Addr() string { ...
- HEOI2018 游记
day0早上没有跑操,收拾了点东西,带了点吃的,老妈打电话说要给送点厚衣服,好像确实有点冷.上午有考试,说自愿考,然后开到一半就没了,根本没人打啊,打了一道小园丁和老司机,一个一个部分分打,最后T了一 ...