From c7971c3293e178b05bf605835c7c97db8acf241a Mon Sep 17 00:00:00 2001 From: Ryohei Ueda Date: Fri, 15 Jul 2022 08:24:57 +0900 Subject: [PATCH 1/5] Support remote mode * Add language-configuration.json files that are included in vscode. * Read the embedded language-configuration.json if no suitable extension is found. * Add script to copy language-configuration.json. --- copy_language_configuration.py | 29 +++ resources/bat/language-configuration.json | 1 + resources/clojure/language-configuration.json | 1 + .../coffeescript/language-configuration.json | 1 + resources/cpp/language-configuration.json | 1 + resources/csharp/language-configuration.json | 1 + resources/css/language-configuration.json | 1 + resources/dart/language-configuration.json | 1 + resources/diff/language-configuration.json | 1 + resources/docker/language-configuration.json | 1 + resources/fsharp/language-configuration.json | 1 + resources/go/language-configuration.json | 1 + resources/groovy/language-configuration.json | 1 + .../handlebars/language-configuration.json | 42 ++++ resources/hlsl/language-configuration.json | 1 + resources/html/language-configuration.json | 1 + resources/java/language-configuration.json | 1 + resources/json/language-configuration.json | 1 + resources/julia/language-configuration.json | 1 + resources/less/language-configuration.json | 1 + resources/lua/language-configuration.json | 1 + resources/make/language-configuration.json | 1 + .../language-configuration.json | 56 +++++ .../objective-c/language-configuration.json | 1 + resources/php/language-configuration.json | 81 ++++++++ .../powershell/language-configuration.json | 1 + resources/pug/language-configuration.json | 1 + resources/python/language-configuration.json | 1 + resources/r/language-configuration.json | 1 + resources/razor/language-configuration.json | 1 + .../language-configuration.json | 1 + resources/ruby/language-configuration.json | 1 + resources/rust/language-configuration.json | 1 + resources/scss/language-configuration.json | 1 + .../shaderlab/language-configuration.json | 1 + .../shellscript/language-configuration.json | 1 + resources/sql/language-configuration.json | 40 ++++ resources/swift/language-configuration.json | 1 + .../language-configuration.json | 193 ++++++++++++++++++ resources/vb/language-configuration.json | 1 + resources/yaml/language-configuration.json | 1 + src/extension.ts | 31 ++- 42 files changed, 500 insertions(+), 7 deletions(-) create mode 100755 copy_language_configuration.py create mode 100644 resources/bat/language-configuration.json create mode 100644 resources/clojure/language-configuration.json create mode 100644 resources/coffeescript/language-configuration.json create mode 100644 resources/cpp/language-configuration.json create mode 100644 resources/csharp/language-configuration.json create mode 100644 resources/css/language-configuration.json create mode 100644 resources/dart/language-configuration.json create mode 100644 resources/diff/language-configuration.json create mode 100644 resources/docker/language-configuration.json create mode 100644 resources/fsharp/language-configuration.json create mode 100644 resources/go/language-configuration.json create mode 100644 resources/groovy/language-configuration.json create mode 100644 resources/handlebars/language-configuration.json create mode 100644 resources/hlsl/language-configuration.json create mode 100644 resources/html/language-configuration.json create mode 100644 resources/java/language-configuration.json create mode 100644 resources/json/language-configuration.json create mode 100644 resources/julia/language-configuration.json create mode 100644 resources/less/language-configuration.json create mode 100644 resources/lua/language-configuration.json create mode 100644 resources/make/language-configuration.json create mode 100644 resources/markdown-basics/language-configuration.json create mode 100644 resources/objective-c/language-configuration.json create mode 100644 resources/php/language-configuration.json create mode 100644 resources/powershell/language-configuration.json create mode 100644 resources/pug/language-configuration.json create mode 100644 resources/python/language-configuration.json create mode 100644 resources/r/language-configuration.json create mode 100644 resources/razor/language-configuration.json create mode 100644 resources/restructuredtext/language-configuration.json create mode 100644 resources/ruby/language-configuration.json create mode 100644 resources/rust/language-configuration.json create mode 100644 resources/scss/language-configuration.json create mode 100644 resources/shaderlab/language-configuration.json create mode 100644 resources/shellscript/language-configuration.json create mode 100644 resources/sql/language-configuration.json create mode 100644 resources/swift/language-configuration.json create mode 100644 resources/typescript-basics/language-configuration.json create mode 100644 resources/vb/language-configuration.json create mode 100644 resources/yaml/language-configuration.json diff --git a/copy_language_configuration.py b/copy_language_configuration.py new file mode 100755 index 0000000..1651c3e --- /dev/null +++ b/copy_language_configuration.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import pathlib +import os +import shutil +import sys + + +def main(path_to_extension): + target_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'resources') + if not os.path.exists(path_to_extension): + raise Exception(f'{path_to_extension} does not exist') + for root, dir, files in os.walk(path_to_extension): + for f in files: + if f == 'language-configuration.json': + language_configuration = os.path.join(root, f) + language_directory = os.path.join( + target_directory, + pathlib.Path(root).relative_to(path_to_extension)) + if not os.path.exists(language_directory): + os.mkdir(language_directory) + print( + f'Copy: {language_configuration} => {language_directory}') + shutil.copy(language_configuration, language_directory) + + +if __name__ == '__main__': + main(sys.argv[1]) diff --git a/resources/bat/language-configuration.json b/resources/bat/language-configuration.json new file mode 100644 index 0000000..7d55510 --- /dev/null +++ b/resources/bat/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"@REM"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["%","%"],["\"","\""]],"folding":{"markers":{"start":"^\\s*(::|REM|@REM)\\s*#region","end":"^\\s*(::|REM|@REM)\\s*#endregion"}}} \ No newline at end of file diff --git a/resources/clojure/language-configuration.json b/resources/clojure/language-configuration.json new file mode 100644 index 0000000..b058b54 --- /dev/null +++ b/resources/clojure/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":";;"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""]],"folding":{"offSide":true}} \ No newline at end of file diff --git a/resources/coffeescript/language-configuration.json b/resources/coffeescript/language-configuration.json new file mode 100644 index 0000000..79fae51 --- /dev/null +++ b/resources/coffeescript/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#","blockComment":["###","###"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"],[" "," "]],"folding":{"offSide":true,"markers":{"start":"^\\s*#region\\b","end":"^\\s*#endregion\\b"}}} \ No newline at end of file diff --git a/resources/cpp/language-configuration.json b/resources/cpp/language-configuration.json new file mode 100644 index 0000000..5703cf5 --- /dev/null +++ b/resources/cpp/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[{"open":"[","close":"]"},{"open":"{","close":"}"},{"open":"(","close":")"},{"open":"'","close":"'","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"],["<",">"]],"wordPattern":"(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)","folding":{"markers":{"start":"^\\s*#pragma\\s+region\\b","end":"^\\s*#pragma\\s+endregion\\b"}}} \ No newline at end of file diff --git a/resources/csharp/language-configuration.json b/resources/csharp/language-configuration.json new file mode 100644 index 0000000..5f255a8 --- /dev/null +++ b/resources/csharp/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"'","close":"'","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string","comment"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["<",">"],["'","'"],["\"","\""]],"folding":{"markers":{"start":"^\\s*#region\\b","end":"^\\s*#endregion\\b"}}} \ No newline at end of file diff --git a/resources/css/language-configuration.json b/resources/css/language-configuration.json new file mode 100644 index 0000000..477f3a1 --- /dev/null +++ b/resources/css/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}","notIn":["string","comment"]},{"open":"[","close":"]","notIn":["string","comment"]},{"open":"(","close":")","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string","comment"]},{"open":"'","close":"'","notIn":["string","comment"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"folding":{"markers":{"start":"^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/","end":"^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/"}},"indentationRules":{"increaseIndentPattern":"(^.*\\{[^}]*$)","decreaseIndentPattern":"^\\s*\\}"},"wordPattern":"(#?-?\\d*\\.\\d\\w*%?)|(::?[\\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\\w-?]+%?|[@#!.])"} \ No newline at end of file diff --git a/resources/dart/language-configuration.json b/resources/dart/language-configuration.json new file mode 100644 index 0000000..7b7719c --- /dev/null +++ b/resources/dart/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}"},{"open":"[","close":"]"},{"open":"(","close":")"},{"open":"'","close":"'","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string"]},{"open":"`","close":"`","notIn":["string","comment"]},{"open":"/**","close":" */","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["<",">"],["'","'"],["\"","\""],["`","`"]]} \ No newline at end of file diff --git a/resources/diff/language-configuration.json b/resources/diff/language-configuration.json new file mode 100644 index 0000000..05f75b3 --- /dev/null +++ b/resources/diff/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#","blockComment":["#"," "]},"brackets":[["{","}"],["[","]"],["(",")"]]} \ No newline at end of file diff --git a/resources/docker/language-configuration.json b/resources/docker/language-configuration.json new file mode 100644 index 0000000..2c1ff17 --- /dev/null +++ b/resources/docker/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]]} \ No newline at end of file diff --git a/resources/fsharp/language-configuration.json b/resources/fsharp/language-configuration.json new file mode 100644 index 0000000..0133591 --- /dev/null +++ b/resources/fsharp/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["(*","*)"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}"},{"open":"[","close":"]"},{"open":"(","close":")"},{"open":"\"","close":"\"","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"folding":{"offSide":true,"markers":{"start":"^\\s*//\\s*#region\\b|^\\s*\\(\\*\\s*#region(.*)\\*\\)","end":"^\\s*//\\s*#endregion\\b|^\\s*\\(\\*\\s*#endregion\\s*\\*\\)"}}} \ No newline at end of file diff --git a/resources/go/language-configuration.json b/resources/go/language-configuration.json new file mode 100644 index 0000000..4b18631 --- /dev/null +++ b/resources/go/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"`","close":"`","notIn":["string"]},{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string","comment"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"],["`","`"]],"indentationRules":{"increaseIndentPattern":"^.*(\\bcase\\b.*:|\\bdefault\\b:|(\\b(func|if|else|switch|select|for|struct)\\b.*)?{[^}\"'`]*|\\([^)\"'`]*)$","decreaseIndentPattern":"^\\s*(\\bcase\\b.*:|\\bdefault\\b:|}[)}]*[),]?|\\)[,]?)$"},"folding":{"markers":{"start":"^\\s*//\\s*#?region\\b","end":"^\\s*//\\s*#?endregion\\b"}}} \ No newline at end of file diff --git a/resources/groovy/language-configuration.json b/resources/groovy/language-configuration.json new file mode 100644 index 0000000..7abfc49 --- /dev/null +++ b/resources/groovy/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]]} \ No newline at end of file diff --git a/resources/handlebars/language-configuration.json b/resources/handlebars/language-configuration.json new file mode 100644 index 0000000..e132410 --- /dev/null +++ b/resources/handlebars/language-configuration.json @@ -0,0 +1,42 @@ +{ + "comments": { + "blockComment": [ "{{!--", "--}}" ] + }, + "brackets": [ + [""], + ["<", ">"], + ["{{", "}}"], + ["{{{", "}}}"], + ["{", "}"], + ["(", ")"] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}"}, + { "open": "[", "close": "]"}, + { "open": "(", "close": ")" }, + { "open": "'", "close": "'" }, + { "open": "\"", "close": "\"" } + ], + "surroundingPairs": [ + { "open": "'", "close": "'" }, + { "open": "\"", "close": "\"" }, + { "open": "<", "close": ">" }, + { "open": "{", "close": "}" } + ], + "wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\$\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\s]+)", + "onEnterRules": [ + { + "beforeText": { "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!\\/)>)[^<]*$", "flags": "i" }, + "afterText": { "pattern": "^<\\/([_:\\w][_:\\w-.\\d]*)\\s*>", "flags": "i" }, + "action": { + "indent": "indentOutdent" + } + }, + { + "beforeText": { "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))(\\w[\\w\\d]*)([^/>]*(?!\\/)>)[^<]*$", "flags": "i" }, + "action": { + "indent": "indent" + } + } + ], +} diff --git a/resources/hlsl/language-configuration.json b/resources/hlsl/language-configuration.json new file mode 100644 index 0000000..a1ee47d --- /dev/null +++ b/resources/hlsl/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""]],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""]]} \ No newline at end of file diff --git a/resources/html/language-configuration.json b/resources/html/language-configuration.json new file mode 100644 index 0000000..c38678b --- /dev/null +++ b/resources/html/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"blockComment":[""]},"brackets":[[""],["<",">"],["{","}"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}"},{"open":"[","close":"]"},{"open":"(","close":")"},{"open":"'","close":"'"},{"open":"\"","close":"\""},{"open":"","notIn":["comment","string"]}],"surroundingPairs":[{"open":"'","close":"'"},{"open":"\"","close":"\""},{"open":"{","close":"}"},{"open":"[","close":"]"},{"open":"(","close":")"},{"open":"<","close":">"}],"colorizedBracketPairs":[],"folding":{"markers":{"start":"^\\s*","end":"^\\s*"}},"wordPattern":"(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\$\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\s]+)","onEnterRules":[{"beforeText":{"pattern":"<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w-.\\d]*)(?:(?:[^'\"/>]|\"[^\"]*\"|'[^']*')*?(?!\\/)>)[^<]*$","flags":"i"},"afterText":{"pattern":"^<\\/([_:\\w][_:\\w-.\\d]*)\\s*>","flags":"i"},"action":{"indent":"indentOutdent"}},{"beforeText":{"pattern":"<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w-.\\d]*)(?:(?:[^'\"/>]|\"[^\"]*\"|'[^']*')*?(?!\\/)>)[^<]*$","flags":"i"},"action":{"indent":"indent"}}],"indentationRules":{"increaseIndentPattern":"<(?!\\?|(?:area|base|br|col|frame|hr|html|img|input|keygen|link|menuitem|meta|param|source|track|wbr)\\b|[^>]*\\/>)([-_\\.A-Za-z0-9]+)(?=\\s|>)\\b[^>]*>(?!.*<\\/\\1>)|)|\\{[^}\"']*$","decreaseIndentPattern":"^\\s*(<\\/(?!html)[-_\\.A-Za-z0-9]+\\b[^>]*>|-->|\\})"}} \ No newline at end of file diff --git a/resources/java/language-configuration.json b/resources/java/language-configuration.json new file mode 100644 index 0000000..f05bb45 --- /dev/null +++ b/resources/java/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]},{"open":"/**","close":" */","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"],["<",">"]],"folding":{"markers":{"start":"^\\s*//\\s*(?:(?:#?region\\b)|(?:))"}}} \ No newline at end of file diff --git a/resources/json/language-configuration.json b/resources/json/language-configuration.json new file mode 100644 index 0000000..e57c3f2 --- /dev/null +++ b/resources/json/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"]],"autoClosingPairs":[{"open":"{","close":"}","notIn":["string"]},{"open":"[","close":"]","notIn":["string"]},{"open":"(","close":")","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]},{"open":"\"","close":"\"","notIn":["string","comment"]},{"open":"`","close":"`","notIn":["string","comment"]}],"wordPattern":"(\"(?:[^\\\\\\\"]*(?:\\\\.)?)*\"?)|[^\\s{}\\[\\],:]+","indentationRules":{"increaseIndentPattern":"({+(?=([^\"]*\"[^\"]*\")*[^\"}]*$))|(\\[+(?=([^\"]*\"[^\"]*\")*[^\"\\]]*$))","decreaseIndentPattern":"^\\s*[}\\]],?\\s*$"}} \ No newline at end of file diff --git a/resources/julia/language-configuration.json b/resources/julia/language-configuration.json new file mode 100644 index 0000000..867184b --- /dev/null +++ b/resources/julia/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#","blockComment":["#=","=#"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],["`","`"],{"open":"\"","close":"\"","notIn":["string","comment"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["`","`"]],"folding":{"markers":{"start":"^\\s*#region","end":"^\\s*#endregion"}},"indentationRules":{"increaseIndentPattern":"^(\\s*|.*=\\s*|.*@\\w*\\s*)[\\w\\s]*(?:[\"'`][^\"'`]*[\"'`])*[\\w\\s]*\\b(if|while|for|function|macro|(mutable\\s+)?struct|abstract\\s+type|primitive\\s+type|let|quote|try|begin|.*\\)\\s*do|else|elseif|catch|finally)\\b(?!(?:.*\\bend\\b[^\\]]*)|(?:[^\\[]*\\].*)$).*$","decreaseIndentPattern":"^\\s*(end|else|elseif|catch|finally)\\b.*$"}} \ No newline at end of file diff --git a/resources/less/language-configuration.json b/resources/less/language-configuration.json new file mode 100644 index 0000000..b554398 --- /dev/null +++ b/resources/less/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"blockComment":["/*","*/"],"lineComment":"//"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}","notIn":["string","comment"]},{"open":"[","close":"]","notIn":["string","comment"]},{"open":"(","close":")","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string","comment"]},{"open":"'","close":"'","notIn":["string","comment"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"folding":{"markers":{"start":"^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/","end":"^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/"}},"indentationRules":{"increaseIndentPattern":"(^.*\\{[^}]*$)","decreaseIndentPattern":"^\\s*\\}"},"wordPattern":"(#?-?\\d*\\.\\d\\w*%?)|(::?[\\w-]+(?=[^,{;]*[,{]))|(([@#.!])?[\\w-?]+%?|[@#!.])"} \ No newline at end of file diff --git a/resources/lua/language-configuration.json b/resources/lua/language-configuration.json new file mode 100644 index 0000000..13b3147 --- /dev/null +++ b/resources/lua/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"--","blockComment":["--[[","]]"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"indentationRules":{"increaseIndentPattern":"^((?!(\\-\\-)).)*((\\b(else|function|then|do|repeat)\\b((?!\\b(end|until)\\b).)*)|(\\{\\s*))$","decreaseIndentPattern":"^\\s*((\\b(elseif|else|end|until)\\b)|(\\})|(\\)))"}} \ No newline at end of file diff --git a/resources/make/language-configuration.json b/resources/make/language-configuration.json new file mode 100644 index 0000000..35b3361 --- /dev/null +++ b/resources/make/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"'","close":"'","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string","comment"]}]} \ No newline at end of file diff --git a/resources/markdown-basics/language-configuration.json b/resources/markdown-basics/language-configuration.json new file mode 100644 index 0000000..6d59777 --- /dev/null +++ b/resources/markdown-basics/language-configuration.json @@ -0,0 +1,56 @@ +{ + "comments": { + // symbols used for start and end a block comment. Remove this entry if your language does not support block comments + "blockComment": [ + "" + ] + }, + // symbols used as brackets + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "colorizedBracketPairs": [ + ], + "autoClosingPairs": [ + { + "open": "{", + "close": "}" + }, + { + "open": "[", + "close": "]" + }, + { + "open": "(", + "close": ")" + }, + { + "open": "<", + "close": ">", + "notIn": [ + "string" + ] + } + ], + "surroundingPairs": [ + ["(", ")"], + ["[", "]"], + ["`", "`"], + ["_", "_"], + ["*", "*"], + ["{", "}"], + ["'", "'"], + ["\"", "\""] + ], + "folding": { + "offSide": true, + "markers": { + "start": "^\\s*", + "end": "^\\s*" + } + }, + "wordPattern": { "pattern": "(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})(((\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark})|[_])?(\\p{Alphabetic}|\\p{Number}|\\p{Nonspacing_Mark}))*", "flags": "ug" }, +} diff --git a/resources/objective-c/language-configuration.json b/resources/objective-c/language-configuration.json new file mode 100644 index 0000000..7abfc49 --- /dev/null +++ b/resources/objective-c/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]]} \ No newline at end of file diff --git a/resources/php/language-configuration.json b/resources/php/language-configuration.json new file mode 100644 index 0000000..e585ebf --- /dev/null +++ b/resources/php/language-configuration.json @@ -0,0 +1,81 @@ +{ + "comments": { + "lineComment": "//", // "#" + "blockComment": [ "/*", "*/" ] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}", "notIn": ["string"] }, + { "open": "[", "close": "]", "notIn": ["string"] }, + { "open": "(", "close": ")", "notIn": ["string"] }, + { "open": "'", "close": "'", "notIn": ["string", "comment"] }, + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, + { "open": "/**", "close": " */", "notIn": ["string"] } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["'", "'"], + ["\"", "\""], + ["`", "`"] + ], + "indentationRules": { + "increaseIndentPattern": "({(?!.*}).*|\\(|\\[|((else(\\s)?)?if|else|for(each)?|while|switch|case).*:)\\s*((/[/*].*|)?$|\\?>)", + "decreaseIndentPattern": "^(.*\\*\\/)?\\s*((\\})|(\\)+[;,])|(\\]\\)*[;,])|\\b(else:)|\\b((end(if|for(each)?|while|switch));))" + }, + "folding": { + "markers": { + "start": "^\\s*(#|\/\/)region\\b", + "end": "^\\s*(#|\/\/)endregion\\b" + } + }, + "wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\-\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)", + "onEnterRules": [ + { + // e.g. /** | */ + "beforeText": "^\\s*\\/\\*\\*(?!\\/)([^\\*]|\\*(?!\\/))*$", + "afterText": "^\\s*\\*\\/$", + "action": { + "indent": "indentOutdent", + "appendText": " * " + } + }, + { + // e.g. /** ...| + "beforeText": "^\\s*\\/\\*\\*(?!\\/)([^\\*]|\\*(?!\\/))*$", + "action": { + "indent": "none", + "appendText": " * " + } + }, + { + // e.g. * ...| + "beforeText": "^(\\t|(\\ \\ ))*\\ \\*(\\ ([^\\*]|\\*(?!\\/))*)?$", + "action": { + "indent": "none", + "appendText": "* ", + }, + }, + { + // e.g. */| + "beforeText": "^(\\t|(\\ \\ ))*\\ \\*\\/\\s*$", + "action": { + "indent": "none", + "removeText": 1 + }, + }, + { + // e.g. *-----*/| + "beforeText": "^(\\t|(\\ \\ ))*\\ \\*[^/]*\\*\\/\\s*$", + "action": { + "indent": "none", + "removeText": 1 + } + } + ] +} diff --git a/resources/powershell/language-configuration.json b/resources/powershell/language-configuration.json new file mode 100644 index 0000000..1967466 --- /dev/null +++ b/resources/powershell/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#","blockComment":["<#","#>"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"@'","close":"\n'@","notIn":["string","comment"]},{"open":"@\"","close":"\n\"@","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string","comment"]},["<#","#>"]],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"folding":{"markers":{"start":"^\\s*#[rR]egion\\b","end":"^\\s*#[eE]nd[rR]egion\\b"}}} \ No newline at end of file diff --git a/resources/pug/language-configuration.json b/resources/pug/language-configuration.json new file mode 100644 index 0000000..f0c6400 --- /dev/null +++ b/resources/pug/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//-"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["'","'"],["\"","\""]],"folding":{"offSide":true}} \ No newline at end of file diff --git a/resources/python/language-configuration.json b/resources/python/language-configuration.json new file mode 100644 index 0000000..011a112 --- /dev/null +++ b/resources/python/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#","blockComment":["\"\"\"","\"\"\""]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}"},{"open":"[","close":"]"},{"open":"(","close":")"},{"open":"\"","close":"\"","notIn":["string"]},{"open":"r\"","close":"\"","notIn":["string","comment"]},{"open":"R\"","close":"\"","notIn":["string","comment"]},{"open":"u\"","close":"\"","notIn":["string","comment"]},{"open":"U\"","close":"\"","notIn":["string","comment"]},{"open":"f\"","close":"\"","notIn":["string","comment"]},{"open":"F\"","close":"\"","notIn":["string","comment"]},{"open":"b\"","close":"\"","notIn":["string","comment"]},{"open":"B\"","close":"\"","notIn":["string","comment"]},{"open":"'","close":"'","notIn":["string","comment"]},{"open":"r'","close":"'","notIn":["string","comment"]},{"open":"R'","close":"'","notIn":["string","comment"]},{"open":"u'","close":"'","notIn":["string","comment"]},{"open":"U'","close":"'","notIn":["string","comment"]},{"open":"f'","close":"'","notIn":["string","comment"]},{"open":"F'","close":"'","notIn":["string","comment"]},{"open":"b'","close":"'","notIn":["string","comment"]},{"open":"B'","close":"'","notIn":["string","comment"]},{"open":"`","close":"`","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"],["`","`"]],"folding":{"offSide":true,"markers":{"start":"^\\s*#\\s*region\\b","end":"^\\s*#\\s*endregion\\b"}},"onEnterRules":[{"beforeText":"^\\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\\s*$","action":{"indent":"indent"}}]} \ No newline at end of file diff --git a/resources/r/language-configuration.json b/resources/r/language-configuration.json new file mode 100644 index 0000000..6eff53e --- /dev/null +++ b/resources/r/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]]} \ No newline at end of file diff --git a/resources/razor/language-configuration.json b/resources/razor/language-configuration.json new file mode 100644 index 0000000..81ee370 --- /dev/null +++ b/resources/razor/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"blockComment":[""]},"brackets":[[""],["{","}"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}"},{"open":"[","close":"]"},{"open":"(","close":")"},{"open":"'","close":"'"},{"open":"\"","close":"\""}],"surroundingPairs":[{"open":"'","close":"'"},{"open":"\"","close":"\""},{"open":"<","close":">"}]} \ No newline at end of file diff --git a/resources/restructuredtext/language-configuration.json b/resources/restructuredtext/language-configuration.json new file mode 100644 index 0000000..f636da8 --- /dev/null +++ b/resources/restructuredtext/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":".."},"brackets":[["(",")"],["<",">"],["[","]"]],"surroundingPairs":[["(",")"],["<",">"],["`","`"],["*","*"],["|","|"],["[","]"]],"autoClosingPairs":[{"open":"(","close":")"},{"open":"<","close":">"},{"open":"'","close":"'"},{"open":"`","close":"`","notIn":["string"]},{"open":"\"","close":"\""},{"open":"[","close":"]"}],"autoCloseBefore":":})>`\\n ","onEnterRules":[{"beforeText":"^\\s*\\.\\. *$|(?"]],"indentationRules":{"increaseIndentPattern":"^.*\\{[^}\"']*$|^.*\\([^\\)\"']*$","decreaseIndentPattern":"^\\s*(\\s*\\/[*].*[*]\\/\\s*)*[})]"},"folding":{"markers":{"start":"^\\s*//\\s*#?region\\b","end":"^\\s*//\\s*#?endregion\\b"}}} \ No newline at end of file diff --git a/resources/scss/language-configuration.json b/resources/scss/language-configuration.json new file mode 100644 index 0000000..acfcb9a --- /dev/null +++ b/resources/scss/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"blockComment":["/*","*/"],"lineComment":"//"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[{"open":"{","close":"}","notIn":["string","comment"]},{"open":"[","close":"]","notIn":["string","comment"]},{"open":"(","close":")","notIn":["string","comment"]},{"open":"\"","close":"\"","notIn":["string","comment"]},{"open":"'","close":"'","notIn":["string","comment"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"folding":{"markers":{"start":"^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/","end":"^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/"}},"indentationRules":{"increaseIndentPattern":"(^.*\\{[^}]*$)","decreaseIndentPattern":"^\\s*\\}"},"wordPattern":"(#?-?\\d*\\.\\d\\w*%?)|(::?[\\w-]*(?=[^,{;]*[,{]))|(([@$#.!])?[\\w-?]+%?|[@#!$.])","onEnterRules":[{"beforeText":"^[\\s]*///.*$","action":{"indent":"none","appendText":"/// "}}]} \ No newline at end of file diff --git a/resources/shaderlab/language-configuration.json b/resources/shaderlab/language-configuration.json new file mode 100644 index 0000000..d577a97 --- /dev/null +++ b/resources/shaderlab/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""]]} \ No newline at end of file diff --git a/resources/shellscript/language-configuration.json b/resources/shellscript/language-configuration.json new file mode 100644 index 0000000..cb541d4 --- /dev/null +++ b/resources/shellscript/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]},{"open":"`","close":"`","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"],["`","`"]],"folding":{"markers":{"start":"^\\s*#\\s*#?region\\b.*","end":"^\\s*#\\s*#?endregion\\b.*"}}} \ No newline at end of file diff --git a/resources/sql/language-configuration.json b/resources/sql/language-configuration.json new file mode 100644 index 0000000..6878d8c --- /dev/null +++ b/resources/sql/language-configuration.json @@ -0,0 +1,40 @@ +{ + "comments": { + "lineComment": "--", + "blockComment": [ "/*", "*/" ] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + { "open": "\"", "close": "\"", "notIn": ["string"] }, + { "open": "N'", "close": "'", "notIn": ["string", "comment"] }, + { "open": "'", "close": "'", "notIn": ["string", "comment"] } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"], + ["`", "`"] + ], + "folding": { + "markers": { + "start": "^\\s*--\\s*#region\\b", + "end": "^\\s*--\\s*#endregion\\b" + } + }, + + // enhancedBrackets:[ + // { openTrigger: 'n', open: /begin$/i, closeComplete: 'end', matchCase: true }, + // { openTrigger: 'e', open: /case$/i, closeComplete: 'end', matchCase: true }, + // { openTrigger: 'n', open: /when$/i, closeComplete: 'then', matchCase: true } + // ], + // noindentBrackets: '()', +} diff --git a/resources/swift/language-configuration.json b/resources/swift/language-configuration.json new file mode 100644 index 0000000..a5d3dec --- /dev/null +++ b/resources/swift/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]},{"open":"`","close":"`","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"],["`","`"]]} \ No newline at end of file diff --git a/resources/typescript-basics/language-configuration.json b/resources/typescript-basics/language-configuration.json new file mode 100644 index 0000000..0726071 --- /dev/null +++ b/resources/typescript-basics/language-configuration.json @@ -0,0 +1,193 @@ +{ + // Note that this file should stay in sync with 'javascript-language-basics/javascript-language-configuration.json' + "comments": { + "lineComment": "//", + "blockComment": [ + "/*", + "*/" + ] + }, + "brackets": [ + [ + "${", + "}" + ], + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ] + ], + "autoClosingPairs": [ + { + "open": "{", + "close": "}" + }, + { + "open": "[", + "close": "]" + }, + { + "open": "(", + "close": ")" + }, + { + "open": "'", + "close": "'", + "notIn": [ + "string", + "comment" + ] + }, + { + "open": "\"", + "close": "\"", + "notIn": [ + "string" + ] + }, + { + "open": "`", + "close": "`", + "notIn": [ + "string", + "comment" + ] + }, + { + "open": "/**", + "close": " */", + "notIn": [ + "string" + ] + } + ], + "surroundingPairs": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "'", + "'" + ], + [ + "\"", + "\"" + ], + [ + "`", + "`" + ], + [ + "<", + ">" + ] + ], + "autoCloseBefore": ";:.,=}])>` \n\t", + "folding": { + "markers": { + "start": "^\\s*//\\s*#?region\\b", + "end": "^\\s*//\\s*#?endregion\\b" + } + }, + "wordPattern": { + "pattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>/\\?\\s]+)", + }, + "indentationRules": { + "decreaseIndentPattern": { + "pattern": "^((?!.*?/\\*).*\\*\/)?\\s*[\\}\\]].*$" + }, + "increaseIndentPattern": { + "pattern": "^((?!//).)*(\\{([^}\"'`/]*|(\\t|[ ])*//.*)|\\([^)\"'`/]*|\\[[^\\]\"'`/]*)$" + }, + // e.g. * ...| or */| or *-----*/| + "unIndentedLinePattern": { + "pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$|^(\\t|[ ])*[ ]\\*/\\s*$|^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$" + } + }, + "onEnterRules": [ + { + // e.g. /** | */ + "beforeText": { + "pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$" + }, + "afterText": { + "pattern": "^\\s*\\*/$" + }, + "action": { + "indent": "indentOutdent", + "appendText": " * " + } + }, + { + // e.g. /** ...| + "beforeText": { + "pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$" + }, + "action": { + "indent": "none", + "appendText": " * " + } + }, + { + // e.g. * ...| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$" + }, + "previousLineText": { + "pattern": "(?=^(\\s*(/\\*\\*|\\*)).*)(?=(?!(\\s*\\*/)))" + }, + "action": { + "indent": "none", + "appendText": "* " + } + }, + { + // e.g. */| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*/\\s*$" + }, + "action": { + "indent": "none", + "removeText": 1 + }, + }, + { + // e.g. *-----*/| + "beforeText": { + "pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$" + }, + "action": { + "indent": "none", + "removeText": 1 + }, + }, + { + "beforeText": { + "pattern": "^\\s*(\\bcase\\s.+:|\\bdefault:)$" + }, + "afterText": { + "pattern": "^(?!\\s*(\\bcase\\b|\\bdefault\\b))" + }, + "action": { + "indent": "indent" + } + } + ] +} diff --git a/resources/vb/language-configuration.json b/resources/vb/language-configuration.json new file mode 100644 index 0000000..6d79ffe --- /dev/null +++ b/resources/vb/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"'"},"brackets":[["{","}"],["[","]"],["(",")"],["<",">"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],{"open":"\"","close":"\"","notIn":["string"]}],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["<",">"]],"folding":{"markers":{"start":"^\\s*#Region\\b","end":"^\\s*#End Region\\b"}}} \ No newline at end of file diff --git a/resources/yaml/language-configuration.json b/resources/yaml/language-configuration.json new file mode 100644 index 0000000..e941bb1 --- /dev/null +++ b/resources/yaml/language-configuration.json @@ -0,0 +1 @@ +{"comments":{"lineComment":"#"},"brackets":[["{","}"],["[","]"],["(",")"]],"autoClosingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"surroundingPairs":[["{","}"],["[","]"],["(",")"],["\"","\""],["'","'"]],"folding":{"offSide":true,"markers":{"start":"^\\s*#\\s*region\\b","end":"^\\s*#\\s*endregion\\b"}},"indentationRules":{"increaseIndentPattern":"^\\s*.*(:|-) ?(&\\w+)?(\\{[^}\"']*|\\([^)\"']*)?$","decreaseIndentPattern":"^\\s+\\}$"}} \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index 017e976..b261966 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -123,17 +123,17 @@ class IndentationRule { } } private createRegExp(s: string): RegExp { - try { - if (s && s.length > 0) { - return new RegExp(s); - } else { + try { + if (s && s.length > 0) { + return new RegExp(s); + } else { + return null; + } + } catch (err) { return null; } - } catch (err) { - return null; } } -} const DEFAULT_BRACKETS = [ ['(', ')'], @@ -308,6 +308,23 @@ function getLanguageConfiguration(id: string): ILanguageConfiguration { } } } + + // If no language config is found, find the configuration from resources directory because + // embedded language extension is not available if remote vscode is used. + const resourceDir = path.join(__dirname, '../resources'); + const languageDirs = fs.readdirSync(resourceDir); + for (const languageDir of languageDirs) { + const languageName = path.basename(languageDir); + if (languageName == documentLanguageId) { + // Hit + const langConfigFilepath = + path.join(resourceDir, languageDir, 'language-configuration.json'); + const configFileContent = fs.readFileSync(langConfigFilepath).toString(); + return mergeLanguageConfiguration( + json.parse(configFileContent) as ILanguageConfiguration, + additionalConfiguration); + } + } return null; } From 6cc6e08c314edb42037d753aba65a45194fc45f1 Mon Sep 17 00:00:00 2001 From: Ryohei Ueda Date: Thu, 11 Aug 2022 00:45:08 +0900 Subject: [PATCH 2/5] Cache ILanguageConfiguration * Do not look for the language configuration files every time. * Store ILanguageConfiguration in LANGUAGE_CONFIGURATION_CACHE variable. --- src/extension.ts | 93 +++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index b261966..9539578 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -160,53 +160,66 @@ const ADDITIONAL_CONFIGURATION_FOR_LANGUAGE: { }, }; -// this method is called when your extension is activated -// your extension is activated the very first time the command is executed +let LANGUAGE_CONFIGURATION_CACHE: { + [id: string]: ILanguageConfiguration +} = {}; + +function runReindentCurrentLineCommand(debug: boolean) { + const editor = vscode.window.activeTextEditor; + if (!editor) { + vscode.window.showInformationMessage('No editor'); + return; + } + const documentLanguageId: string = editor.document.languageId; + + // If documentLanguageId is not found in LANGUAGE_CONFIGURATION_CACHE, try to update + // LANGUAGE_CONFIGURATION_CACHE first. + if (!(documentLanguageId in LANGUAGE_CONFIGURATION_CACHE)) { + const languageConfig = getLanguageConfiguration(documentLanguageId); + if (languageConfig) { + LANGUAGE_CONFIGURATION_CACHE[documentLanguageId] = languageConfig; + } + else { + vscode.window.showInformationMessage( + `no language config for ${documentLanguageId}`); + return; + } + } + + const langConfig = LANGUAGE_CONFIGURATION_CACHE[documentLanguageId]; + const [previousValidLine, currentLine] = getPreviousAndCurrentLine(editor); + const indent = + estimateIndentAction(previousValidLine, currentLine, langConfig); + if (debug) { + vscode.window.showInformationMessage(convertIndentActionToString(indent)); + } + else { + reindentCurrentLine(indent, previousValidLine, currentLine); + } +} + export function activate(context: vscode.ExtensionContext) { - // The command has been defined in the package.json file - // Now provide the impleme { + const languageConfig = getLanguageConfiguration(d.languageId); + if (languageConfig) { + LANGUAGE_CONFIGURATION_CACHE[d.languageId] = languageConfig; + } + }); + + // Register commands const reindentCurrentLineCommand = vscode.commands.registerCommand('emacs-tab.reindentCurrentLine', () => { - const editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor'); - return; - } - const documentLanguageId: string = editor.document.languageId; - const langConfig = getLanguageConfiguration(documentLanguageId); - if (!langConfig) { - vscode.window.showInformationMessage( - `no language config for ${documentLanguageId}`); - return; - } - const [previousValidLine, currentLine] = - getPreviousAndCurrentLine(editor); - const indent = - estimateIndentAction(previousValidLine, currentLine, langConfig); - reindentCurrentLine(indent, previousValidLine, currentLine); + runReindentCurrentLineCommand(false); }); const debugEstimateIndentLevel = vscode.commands.registerCommand( 'emacs-tab.debugEstimateIndentLevel', () => { - const editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor'); - return; - } - const documentLanguageId: string = editor.document.languageId; - const langConfig = getLanguageConfiguration(documentLanguageId); - if (!langConfig) { - vscode.window.showInformationMessage( - `no language config for ${documentLanguageId}`); - return; - } - const [previousValidLine, currentLine] = - getPreviousAndCurrentLine(editor); - const indent = - estimateIndentAction(previousValidLine, currentLine, langConfig); - vscode.window.showInformationMessage( - convertIndentActionToString(indent)); + runReindentCurrentLineCommand(true); }); context.subscriptions.push(reindentCurrentLineCommand); } From 53f1580ed39c03bc2e6681988f949e8ab753ab79 Mon Sep 17 00:00:00 2001 From: Ryohei Ueda Date: Thu, 11 Aug 2022 00:48:44 +0900 Subject: [PATCH 3/5] Support language specific tabsize configuration --- src/extension.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 9539578..53d7ad5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -194,7 +194,7 @@ function runReindentCurrentLineCommand(debug: boolean) { vscode.window.showInformationMessage(convertIndentActionToString(indent)); } else { - reindentCurrentLine(indent, previousValidLine, currentLine); + reindentCurrentLine(indent, previousValidLine, currentLine, documentLanguageId); } } @@ -439,9 +439,9 @@ function createCloseBracketRegExp(closeBracket: string): RegExp { return createRegExp(str); } -function getTabSize(): number { +function getTabSize(languageId: string): number { // TODO: estimate from content - return vscode.workspace.getConfiguration('editor').tabSize; + return vscode.workspace.getConfiguration('editor', {languageId: languageId}).tabSize; } /** @@ -485,8 +485,8 @@ function convertIndentLevelToString( */ export function reindentCurrentLine( indentAction: vscode.IndentAction, validPreviousLine: string, - currentLine: string): void { - const tabSize = getTabSize(); + currentLine: string, languageId: string): void { + const tabSize = getTabSize(languageId); const editor = vscode.window.activeTextEditor; const currentPosition = editor.selection.active; const document = editor.document; From 7287a237712b9d34eb6fbc339d7c77ec6c78c330 Mon Sep 17 00:00:00 2001 From: Ryohei Ueda Date: Thu, 11 Aug 2022 00:50:38 +0900 Subject: [PATCH 4/5] Update language-configuration.json --- resources/json/language-configuration.json | 2 +- .../language-configuration.json | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/resources/json/language-configuration.json b/resources/json/language-configuration.json index e57c3f2..65a5492 100644 --- a/resources/json/language-configuration.json +++ b/resources/json/language-configuration.json @@ -1 +1 @@ -{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"]],"autoClosingPairs":[{"open":"{","close":"}","notIn":["string"]},{"open":"[","close":"]","notIn":["string"]},{"open":"(","close":")","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]},{"open":"\"","close":"\"","notIn":["string","comment"]},{"open":"`","close":"`","notIn":["string","comment"]}],"wordPattern":"(\"(?:[^\\\\\\\"]*(?:\\\\.)?)*\"?)|[^\\s{}\\[\\],:]+","indentationRules":{"increaseIndentPattern":"({+(?=([^\"]*\"[^\"]*\")*[^\"}]*$))|(\\[+(?=([^\"]*\"[^\"]*\")*[^\"\\]]*$))","decreaseIndentPattern":"^\\s*[}\\]],?\\s*$"}} \ No newline at end of file +{"comments":{"lineComment":"//","blockComment":["/*","*/"]},"brackets":[["{","}"],["[","]"]],"autoClosingPairs":[{"open":"{","close":"}","notIn":["string"]},{"open":"[","close":"]","notIn":["string"]},{"open":"(","close":")","notIn":["string"]},{"open":"'","close":"'","notIn":["string"]},{"open":"\"","close":"\"","notIn":["string","comment"]},{"open":"`","close":"`","notIn":["string","comment"]}],"indentationRules":{"increaseIndentPattern":"({+(?=((\\\\.|[^\"\\\\])*\"(\\\\.|[^\"\\\\])*\")*[^\"}]*)$)|(\\[+(?=((\\\\.|[^\"\\\\])*\"(\\\\.|[^\"\\\\])*\")*[^\"\\]]*)$)","decreaseIndentPattern":"^\\s*[}\\]],?\\s*$"}} \ No newline at end of file diff --git a/resources/typescript-basics/language-configuration.json b/resources/typescript-basics/language-configuration.json index 0726071..739f085 100644 --- a/resources/typescript-basics/language-configuration.json +++ b/resources/typescript-basics/language-configuration.json @@ -99,6 +99,24 @@ ">" ] ], + "colorizedBracketPairs": [ + [ + "(", + ")" + ], + [ + "[", + "]" + ], + [ + "{", + "}" + ], + [ + "<", + ">" + ] + ], "autoCloseBefore": ";:.,=}])>` \n\t", "folding": { "markers": { From bc5cae6fdcf35d7da2391289445b709cff2962ef Mon Sep 17 00:00:00 2001 From: Ryohei Ueda Date: Thu, 11 Aug 2022 21:55:30 +0900 Subject: [PATCH 5/5] Bump up version to 0.0.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7bb5062..217980c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-emacs-tab", "displayName": "vscode-emacs-tab", "description": "emacs like tab behavior", - "version": "0.0.9", + "version": "0.0.10", "publisher": "garaemon", "repository": { "type": "git",