Skip to content

Commit

Permalink
Merge pull request #104 from JelleInfinity/pr
Browse files Browse the repository at this point in the history
Small fixes in python block and new indenting rules
  • Loading branch information
LuqueDaniel authored May 2, 2022
2 parents fc15091 + c17b6f2 commit 4dd2fcb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 48 deletions.
87 changes: 52 additions & 35 deletions language-configuration.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,56 @@
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": "#"
"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": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] },
{ "open": "`", "close": "`", "notIn": ["string"] },
{ "open": "\"\"\"", "close": "\"\"\"", "notIn": ["string"] }
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["`", "`"],
["\"\"\"", "\"\"\""]
],
"folding": {
"offSide": true,
"markers": {
"start": "^\\s*#\\s*region\\b",
"end": "^\\s*#\\s*endregion\\b"
}
},
"onEnterRules": [
//Renpy keywords
{
"beforeText": "^\\s*\\b(?:label|menu|python|init|screen|transform)\\b.*:\\s*$",
"action": { "indent": "indent" }
},
//Python keywords available in renpy code
{
"beforeText": "^\\s*\\b(?:for|if|elif|else|while)\\b.*:\\s*$",
"action": { "indent": "indent" }
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string"] },
{ "open": "`", "close": "`", "notIn": ["string"] },
{ "open": "\"\"\"", "close": "\"\"\"", "notIn": ["string"] }
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["`", "`"],
["\"\"\"", "\"\"\""]
],
"folding": {
"markers": {
"start": "^#region",
"end": "^#endregion"
},
"offSide": true
//For menu's
{
"beforeText": "^\\s+(?:\".*?\"|\\'.*?\\')\\s*:\\s*$",
"action": { "indent": "indent" }
}
]
}
10 changes: 0 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ let myStatusBarItem: StatusBarItem;
export async function activate(context: ExtensionContext): Promise<any> {
console.log("Ren'Py extension activated");

languages.setLanguageConfiguration("renpy", {
onEnterRules: [
{
// indentation for Ren'Py and Python blocks
beforeText: /^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|label|menu|init|\":|\':|python|).*?:\s*$/,
action: { indentAction: IndentAction.Indent },
},
],
});

const filepath = getNavigationJsonFilepath();
const jsonFileExists = fs.existsSync(filepath);
if (!jsonFileExists) {
Expand Down
6 changes: 3 additions & 3 deletions syntaxes/renpy.tmLanguage_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"comment": "Renpy python block",
"contentName": "meta.embedded.block.python",

"begin": "(^[ \\t]+)?\\b(?:(init) (?:(-)?(\\d*) )?)?(python)([\\w \\t]*)(:)",
"begin": "(^[ \\t]+)?(?:\\b(init)\\b\\s+(?:(-)?(\\d*)\\s+)?)?\\b(python)\\b(.*?)(:)",
"beginCaptures": {
"1": {
"name": "punctuation.whitespace.embedded.leading.python"
Expand All @@ -36,12 +36,12 @@
"name": "keyword.renpy"
},
"6": {
"name": "meta.embedded.block.python.options",
"name": "meta.python.block.arguments.renpy",

"patterns": [
{
"comment": "in statement",
"match": "(?: (in) ([a-zA-Z_]\\w+))",
"match": "(?:\\s*(in)\\s*([a-zA-Z_]\\w*)\\b)",
"captures": {
"1": {
"name": "keyword.renpy"
Expand Down

0 comments on commit 4dd2fcb

Please sign in to comment.