This is my goal to achieve:
这是我要实现的目标:
This is what I get:
这就是我得到的:
My little syntax highlighting vscode extension looks like this:
我突出显示vscode扩展的小语法如下所示:
package.json (significant excerpt)
Package.json(重要摘录)
"contributes": {
"languages": [{
"id": "foo",
"extensions": [".foo"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "foo",
"scopeName": "source.foo",
"path": "./syntaxes/foo.tmLanguage.json"
}],
"themes": [
{
"label": "dark",
"uiTheme": "vs-dark",
"path": "./themes/d-color-theme.json"
}
]
}
language-configuration.json
Language-configuration.json
{
"comments": {
"lineComment": "//",
"blockComment": [ "\/*", "*\/" ]
}
}
syntaxes/foo.tmLanguage.json
语法/foo.tmLanguage.json
{
"name": "Foo Language",
"patterns": [
{
"include": "#longComments"
},
{
"include": "#shortComments"
},
{
"include": "#pascalCase"
},
{
"include": "#camelCase"
}
],
"repository": {
"longComments": {
"patterns": [{
"name": "blockComment.foo",
"match": "\/*((?:.|\n)*?)*\/"
}]
},
"camelCase": {
"patterns": [{
"name": "camelCase.foo",
"match": "[a-z][a-z0-9A-Z_]*"
}]
},
"pascalCase": {
"patterns": [{
"name": "pascalCase.foo",
"match": "[A-Z][a-z0-9A-Z_]*"
}]
},
"shortComments": {
"patterns": [{
"name": "lineComment.foo",
"match": "\/\/[^\n]*"
}]
}
},
"scopeName": "source.foo"
}
themes/dark-color-theme.json
主题/深色主题.json
{
"name": "dark",
"colors": {
"editor.background": "#263238",
"editor.foreground": "#eeffff",
"activityBarBadge.background": "#007acc",
"sideBarTitle.foreground": "#bbbbbb"
},
"tokenColors": [
{
"name": "Pascal Case Identifiers",
"scope": [
"pascalCase.foo"
],
"settings": {
"foreground": "#06d44a"
}
},
{
"name": "Comment",
"scope": [
"blockComment.foo",
"lineComment.foo"
],
"settings": {
"fontStyle": "italic",
"foreground": "#546E7A"
}
},
{
"name": "Camel Case Identifiers",
"scope": [
"camelCase.foo"
],
"settings": {
"foreground": "#f7c63f"
}
}
]
}
What I tried is to replace the longComments
specification in:
我尝试的是将LongComments规范替换为:
syntaxes/foo.tmLanguage.json (excerpt with replacement)
语法/foo.tmLanguage.json(带替换的摘录)
"longComments": {
"name": "blockComment.foo",
"begin": "\/*",
"end": "*\/",
"patterns": [
{
"name": "character.foo",
"match": "((?:.|\n)*?)*"
}
]
}
but then I see this:
但后来我看到了这个:
This is my test text. You can copy-paste to reproduce the behavior.
这是我的测试文本。您可以复制粘贴以重现该行为。
// an Inline comment
// an Inline comment that is even longer
PascalCaseWord AnotherPascalCaseWord
camelCaseWord, anotherCamelCaseWord
/* This is another multiline comment with some PascalCaseWord and some camelCaseWord */
/* This is another multiline comment with some PascalCaseWord and some camelCaseWord
that goes over two lines . */
/* This is another multiline comment with
some PascalCaseWord
and some camelCaseWord
that goes over three lines . */
How can I achieve my goal (see first screenshot)?
我如何实现我的目标(见第一个屏幕截图)?
更多回答
我是一名优秀的程序员,十分优秀!