私は、文書作成ツールで使用するルール用に独自の構文強調表示拡張機能を作成しようとしています。
私はそれのほとんどを正常に動作させることができましたが、コメントをスコープインスペクターに認識させることができません。
競合を排除するために tmLanguage ファイルから他のすべての作業コードを削除したところ、次のようになりました。
ote-rules.tmLanguage.json
{
"scopeName": "source.ote-rules",
"patterns": [{
"include": "#expression"
}],
"repository": {
"expression": {
"patterns": [
{
"include": "#comments-ote"
}
]
},
"comments-ote": {
"patterns": [{
"include": "#comments-block"
},
{
"include": "#comments-line"
}
],
"comments-line": {
"match": "\\/\\/.*?$",
"name": "comment.line.double-slash.ote-rules"
},
"comments-block": {
"begin": "\\/\\*",
"end": "\\*\\/",
"beginCaptures":{
"0":{"name":"punctuation.definition.comment.ote-rules"}
},
"endCaptures":{
"0":{"name":"punctuation.definition.comment.ote-rules"}
}
}
}
}
}
照合しようとしているファイルはプレーン テキスト ファイル (*.txt
拡張子) であり、コメントは 2 つのスラッシュを含む行コメントか、および で始まり、それぞれ終わるブロック コメント/*
です*/
。
テストテキストファイル.txt
// just some comment text
// indented comment
//
// left the above line empty apart from slashes
/*
inline block comment
*/
スコープ インスペクターで上記のテキストを見ると、source.ote-rules からのものであることが認識されますが、トークンの種類が「その他」として表示されます。
rubular.com で正規表現を確認しましたが、それらは私が示したサンプルで動作しているように見えます。