Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some small improvements #45

Merged
merged 2 commits into from
Mar 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions nimcfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"comments": {
"lineComment": "#",
"blockComment": [ "#[", "]#" ]
},
"brackets": [
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont sure that this is good idea to use json configuration together with code based in nimMain.ts, also autoClosingPairs is marked as Deprecated in https://github.com/Microsoft/vscode/blob/master/src/vs/vscode.d.ts#L2786
May be it will more reasonable use declaration in code for better type safety?

Copy link
Contributor Author

@RSDuck RSDuck Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really deprecated if it's inside a json configuration? Because the source code states:

/**
* **Deprecated** Do not use.
*
* @deprecated * Use the the autoClosingPairs property in the language configuration file instead.
*/

That's the reason why I created a json language config file anyway. And here in the official manual they still recommend autoClosingPairs in json configs. Also e.g. the Python extension(integrated into VSCode) depends on autoClosingPairs, otherwise they would have the same problem.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

["#[", "]#"],
{"open": "[", "close": "]", "notIn": ["comment"]},
["(", ")"],
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] }
],
"surroundingPairs": [
["[", "]"],
["(", ")"],
["'", "'"],
["\"", "\""]
]
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
24 changes: 1 addition & 23 deletions src/nimMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down