wjm*_*ann 1 grammar json syntax-highlighting visual-studio-code vscode-extensions
因此,我正在开展一个研究项目,该项目涉及使用一个非常特定的软件,该软件使用自己的文件类型;XPPAUT 使用 .ode 文件。为了防止我和我的非神经科学家团队费尽心思地尝试解决这个问题,我决定为这些 .ode 文件编写一个语法荧光笔。
首先,我只是想能够识别行注释并为其着色,这些行注释用 来描绘#,类似于 Python,但是当我运行开发环境时,注释不会用我设置的开发工作区使用的颜色突出显示,也不会突出显示根本不。我对此很陌生,所以任何帮助将不胜感激。
这是我的package.json文件
{
"name": "ode",
"displayName": "XPP ODE",
"description": "ODE files to be used with XPP/XPPAUT",
"version": "0.0.1",
"publisher": "wjmccann",
"engines": {
"vscode": "^1.22.0"
},
"categories": [
"Languages"
],
"contributes": {
"languages": [{
"id": "xpp",
"aliases": ["XPP ODE", "XPP", "XPPAUT"],
"extensions": [".ode"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "xpp",
"scopeName": "source.xpp",
"path": "./syntaxes/xpp.tmLanguage.json"
}]
}
}
Run Code Online (Sandbox Code Playgroud)
以及相应的language-configuration.json
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": "#",
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
Run Code Online (Sandbox Code Playgroud)
小智 5
该language-configuration.json文件定义了 VS Code 的各种标准功能中使用的文本模式,例如此处所述的注释切换。
语法突出显示/着色是通过grammars贡献点进行的,如此处package.json所述。
根据您的情况,package.json您将需要创建一个./syntaxes/xpp.tmLanguage.json包含以下内容的新文件,以便您的评论被适当地着色。实际使用的颜色取决于您当前的主题。
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "xpp",
"scopeName": "source.xpp",
"patterns": [
{
"include": "#comments"
}
],
"repository": {
"comments": {
"patterns": [{
"name": "comment.line.number-sign.xpp",
"match": "#.*"
}]
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1592 次 |
| 最近记录: |