diff --git a/.gitmodules b/.gitmodules index fda68b55..50616ed2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -236,3 +236,6 @@ [submodule "assets/syntaxes/02_Extra/Dart"] path = assets/syntaxes/02_Extra/Dart url = https://github.com/elMuso/Dartlight.git +[submodule "assets/syntaxes/02_Extra/SublimeJQ"] + path = assets/syntaxes/02_Extra/SublimeJQ + url = https://github.com/zogwarg/SublimeJQ.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 01facab0..56d28a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Associate `_vimrc` and `_gvimrc` files with the `VimL` syntax. See #2002 - Associate `poetry.lock` files with the `TOML` syntax. See #2049 - Associate `.mesh`, `.task`, `.rgen`, `.rint`, `.rahit`, `.rchit`, `.rmiss`, and `.rcall` with the `GLSL` syntax. See #2050 +- Added support for `JQ` syntax, see #2072 ## Themes diff --git a/assets/syntaxes/02_Extra/SublimeJQ b/assets/syntaxes/02_Extra/SublimeJQ new file mode 160000 index 00000000..68705828 --- /dev/null +++ b/assets/syntaxes/02_Extra/SublimeJQ @@ -0,0 +1 @@ +Subproject commit 687058289c1a888e0895378432d66b41609a84d8 diff --git a/tests/syntax-tests/highlighted/JQ/sample.jq b/tests/syntax-tests/highlighted/JQ/sample.jq new file mode 100644 index 00000000..ba9c853f --- /dev/null +++ b/tests/syntax-tests/highlighted/JQ/sample.jq @@ -0,0 +1,60 @@ +import "../imported-file" ; + +# With Comments ! +def weird($a; $b; $c): + [ $a, $b, $c ] | transpose | reduce .[][] as $item ( + []; + . + $item.property + ) +; + +. | weird (.a; .b; .c) | + +( + +if (. | contains("never") ) then + "Why yes" +else + 12.23 +end + +) as $never | + +{ + hello, + why: "because", + hello: ( weird | ascii_upcase ), + format_eg: ( . | @json "My json string \( . | this | part | just | white | ascii_upcase | transpose)" ), + never: $never, + "literal_key": literal_value, + "this": 12.1e12, + "part": "almost" + "like": [ + 12, + 2 + "json" + { + "quite": { + similar: "but not quite" + } + } + ], +} | ( +  + # And with very basic brace matching +  + # Invalid End + ]  +  + # Other invalid ends + ( [ } ] ) + + # A "valid" sequence + ( [ { key: () , other_key:( [ [] [[]] ] ), gaga } ] ) + + # A "invalid" sequence + ( [ { key: () , other_key:( [ [] [[] ] ), gaga } ] ) + + "A string\n whith escaped characters \" because we can" +) + diff --git a/tests/syntax-tests/source/JQ/LICENSE.md b/tests/syntax-tests/source/JQ/LICENSE.md new file mode 100644 index 00000000..b6204556 --- /dev/null +++ b/tests/syntax-tests/source/JQ/LICENSE.md @@ -0,0 +1,25 @@ +The `sample.jq` file was taken from [SublimeJQ] under the following license: + +[SublimeJQ]: https://github.com/zogwarg/SublimeJQ + +MIT License + +Copyright (c) 2017 Thomas Buick + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tests/syntax-tests/source/JQ/sample.jq b/tests/syntax-tests/source/JQ/sample.jq new file mode 100644 index 00000000..ec458f6c --- /dev/null +++ b/tests/syntax-tests/source/JQ/sample.jq @@ -0,0 +1,60 @@ +import "../imported-file" ; + +# With Comments ! +def weird($a; $b; $c): + [ $a, $b, $c ] | transpose | reduce .[][] as $item ( + []; + . + $item.property + ) +; + +. | weird (.a; .b; .c) | + +( + +if (. | contains("never") ) then + "Why yes" +else + 12.23 +end + +) as $never | + +{ + hello, + why: "because", + hello: ( weird | ascii_upcase ), + format_eg: ( . | @json "My json string \( . | this | part | just | white | ascii_upcase | transpose)" ), + never: $never, + "literal_key": literal_value, + "this": 12.1e12, + "part": "almost" + "like": [ + 12, + 2 + "json" + { + "quite": { + similar: "but not quite" + } + } + ], +} | ( + + # And with very basic brace matching + + # Invalid End + ] + + # Other invalid ends + ( [ } ] ) + + # A "valid" sequence + ( [ { key: () , other_key:( [ [] [[]] ] ), gaga } ] ) + + # A "invalid" sequence + ( [ { key: () , other_key:( [ [] [[] ] ), gaga } ] ) + + "A string\n whith escaped characters \" because we can" +) +