From da4c69a9ddac7cb7d7949f6b0924dd54352d4457 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Mon, 27 Feb 2017 23:27:35 +0100 Subject: [PATCH 1/2] Refixed #32 --- nimcfg.json | 23 +++++++++++++++++++++++ package.json | 3 ++- src/nimMain.ts | 22 ---------------------- 3 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 nimcfg.json diff --git a/nimcfg.json b/nimcfg.json new file mode 100644 index 0000000..95252dc --- /dev/null +++ b/nimcfg.json @@ -0,0 +1,23 @@ +{ + "comments": { + "lineComment": "#", + "blockComment": [ "#[", "]#" ] + }, + "brackets": [ + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + ["#[", "]#"], + {"open": "[", "close": "]", "notIn": ["comment"]}, + ["(", ")"], + { "open": "'", "close": "'", "notIn": ["string", "comment"] }, + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] } + ], + "surroundingPairs": [ + ["[", "]"], + ["(", ")"], + ["'", "'"], + ["\"", "\""] + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 6ffad02..dd71fcb 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,8 @@ { "id": "nim", "aliases": ["Nim", "nim"], - "extensions": [".nim", ".nims", "nim.cfg", ".nim.cfg"] + "extensions": [".nim", ".nims", "nim.cfg", ".nim.cfg"], + "configuration": "./nimcfg.json" }, { "id": "nimble", diff --git a/src/nimMain.ts b/src/nimMain.ts index 1714a6a..e2670c2 100644 --- a/src/nimMain.ts +++ b/src/nimMain.ts @@ -45,28 +45,6 @@ export function activate(ctx: vscode.ExtensionContext): void { decreaseIndentPattern: /^\s*(((return|break|continue|raise)\n)|((elif|else|except|finally)\b.*:))\s*$/ }, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, - onEnterRules: [ - { - beforeText: /^ *#\s.*$/, - afterText: /.+$/, - action: { indentAction: vscode.IndentAction.None, appendText: '# ' } - }, - { - beforeText: /^ *##\s.*$/, - afterText: /.+$/, - action: { indentAction: vscode.IndentAction.None, appendText: '## ' } - } - ], - comments: { - lineComment: '#', - blockComment: ['#[', ']#'], - }, - brackets: [ - ['[', ']'], - ['(', ')'], - ['"', '"'], - ['\'', '\''] - ] }); vscode.window.onDidChangeActiveTextEditor(showHideStatus, null, ctx.subscriptions); From c62a119343ce9c156ddccd51c172c23e8c2a4754 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Wed, 15 Mar 2017 18:55:06 +0100 Subject: [PATCH 2/2] Auto bracket closing for nimble files and improved identation pattern --- nimcfg.json | 1 - package.json | 3 ++- src/nimMain.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nimcfg.json b/nimcfg.json index 95252dc..bf95757 100644 --- a/nimcfg.json +++ b/nimcfg.json @@ -11,7 +11,6 @@ ["#[", "]#"], {"open": "[", "close": "]", "notIn": ["comment"]}, ["(", ")"], - { "open": "'", "close": "'", "notIn": ["string", "comment"] }, { "open": "\"", "close": "\"", "notIn": ["string", "comment"] } ], "surroundingPairs": [ diff --git a/package.json b/package.json index dd71fcb..fb528a9 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,8 @@ { "id": "nimble", "aliases": ["Nimble", "nimble"], - "extensions": [".nimble"] + "extensions": [".nimble"], + "configuration": "./nimcfg.json" } ], "grammars": [ diff --git a/src/nimMain.ts b/src/nimMain.ts index e2670c2..e70ee43 100644 --- a/src/nimMain.ts +++ b/src/nimMain.ts @@ -41,7 +41,7 @@ export function activate(ctx: vscode.ExtensionContext): void { vscode.languages.setLanguageConfiguration(NIM_MODE.language, { indentationRules: { - increaseIndentPattern: /^\s*(((if|when|elif|else|except|finally|for|try|while|of)\b.*:)|((proc|macro|iterator|template|converter)\b.*\=)|(import|var|const|type))\s*$/, + increaseIndentPattern: /^\s*((((proc|macro|iterator|template|converter)\b.*\=)|(import|var|const|type)\s)|(import|let|var|const|type)|([^:]+:))$/, decreaseIndentPattern: /^\s*(((return|break|continue|raise)\n)|((elif|else|except|finally)\b.*:))\s*$/ }, wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,