Visual Studio的代码编辑器挺强大的,自带了许多语法高亮支持。但是万一碰到不支持的怎么办?
可以先看看这个加件[SyntaxHighlightingPack],里面提供许多额外的语法高亮支持。
如果还是没有你想要的语法高亮,也不要着急,Visual Studio支持使用TextMate的语法高亮文件(tmLanguage或者json格式的)。以Flatbuffers为例,可以使用从https://github.com/gaborv/FlatbuffersSchema下载json格式的语法高亮文件。
根据Add Visual Studio editor support for other languages的Add support for non-supported languages的说明,只要进入到%userprofile%\.vs\Extensions
目录,创建一个空的fbs目录(假设flatbuffers的扩展名为fbs),然后进入fbs目录,执行下面的git命令下载语法高亮文件即可:
git clone --depth=1 https://github.com/gaborv/FlatbuffersSchema.git .
其他参考
- Create a syntax highlighter for Visual Studio and Visual Code with TextMate Bundle
- https://github.com/Seddryck/genbil-tmbundle
- https://github.com/madskristensen/TextmateBundleInstaller
- https://github.com/madskristensen/TextmateSample
- https://github.com/SrTobi/language-flatbuffers
- adding a new textmate grammar to visual studio 2015 update 1
其他
- https://github.com/google/flatbuffers/issues/5402
- https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/implementing-syntax-coloring?view=vs-2019
- https://docs.microsoft.com/en-us/visualstudio/extensibility/syntax-coloring-in-custom-editors?view=vs-2019
(完)