我正在尝试将用于Atom https://atom.io/packages/language-sas的SAS语言扩展名移植到VScode。除了自动缩进之外,一切正常(语法等)。
我使用yo code
为SAS语言扩展创建了模板。我尝试使用与Atom中相同的正则表达式,但它们似乎不起作用。我还尝试了一些非常简单的设置,例如"increaseIndentPattern": "^\s*(data|proc)\s*;$
,但它们似乎也不起作用。
我目前已安装以下扩展:Python,Remote-SSH,TSLint,Visual Studio Intellicode,Tomorrow颜色主题。
这是我的package.json
和language-configuration.json
:
{
"name": "sas-language",
"displayName": "SAS",
"description": "SAS language support for Visual Studio Code",
"version": "0.0.1",
"engines": {
"vscode": "^1.36.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [
{
"id": "sas",
"aliases": [
"SAS",
"sas"
],
"extensions": [
".sas"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "sas",
"scopeName": "source.sas",
"path": "./syntaxes/language-sas.json"
}
],
"snippets": [
{
"language": "sas",
"path": "./snippets/language-sas.json"
}
]
}
}
{
"comments": {
"lineComment": "*",
"blockComment": ["/*", "*/"]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{"open": "{", "close": "}"},
{"open": "[", "close": "]"},
{"open": "(", "close": ")"},
{"open": "\"", "close": "\"", "notIn": ["string", "comment"]},
{"open": "'", "close": "'", "notIn": ["string", "comment"]}
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
"indentationRules": {
"increaseIndentPattern": "(?i:(\\bdo\\b(.(?!end;))*$|\\bbegingraph\\b(.(?!endgraph;))*$|^\\s*(proc|data|%macro)\\s+.*;\\s*$))",
"decreaseIndentPattern": "(?i:(^\\s*(%?end|endgraph|endsas|run|quit|%mend)\\s*;))"
}
}
答案 0 :(得分:0)
在以下两个问题中找到了您的问题的答案:https://github.com/microsoft/vscode/issues/74493和https://github.com/microsoft/vscode/issues/27591#issuecomment-305175307。
问题出在忽略大小写修饰符(?i:)
上。显然,这是未记录的行为。删除(?i:)
修饰符,然后将regex_string替换为{"pattern": regex_string; flags: "i"}
。因此,代替:
"increaseIndentPattern": "(?i)...your regex here..."
写:
"increaseIndentPattern": {"pattern": "(?i)...your regex here...", "flags": "i"}
您的缩进规则变为:
"indentationRules": {
"increaseIndentPattern": {"pattern": "\\bdo\\b(.(?!end;))*$|\\bbegingraph\\b(.(?!endgraph;))*$|^\\s*(proc|data|%macro)\\s+.*;\\s*$", "flags": "i"},
"decreaseIndentPattern": {"pattern": "^\\s*(%?end|endgraph|endsas|run|quit|%mend|((proc|data)\\s+.*))\\s*;", "flags": "i"}
}