diff --git a/nimcfg.json b/nimcfg.json new file mode 100644 index 0000000..bf95757 --- /dev/null +++ b/nimcfg.json @@ -0,0 +1,22 @@ +{ + "comments": { + "lineComment": "#", + "blockComment": [ "#[", "]#" ] + }, + "brackets": [ + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + ["#[", "]#"], + {"open": "[", "close": "]", "notIn": ["comment"]}, + ["(", ")"], + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] } + ], + "surroundingPairs": [ + ["[", "]"], + ["(", ")"], + ["'", "'"], + ["\"", "\""] + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 6ffad02..fb528a9 100644 --- a/package.json +++ b/package.json @@ -60,12 +60,14 @@ { "id": "nim", "aliases": ["Nim", "nim"], - "extensions": [".nim", ".nims", "nim.cfg", ".nim.cfg"] + "extensions": [".nim", ".nims", "nim.cfg", ".nim.cfg"], + "configuration": "./nimcfg.json" }, { "id": "nimble", "aliases": ["Nimble", "nimble"], - "extensions": [".nimble"] + "extensions": [".nimble"], + "configuration": "./nimcfg.json" } ], "grammars": [ diff --git a/src/nimMain.ts b/src/nimMain.ts index 1714a6a..e70ee43 100644 --- a/src/nimMain.ts +++ b/src/nimMain.ts @@ -41,32 +41,10 @@ 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, - 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);