Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter committed Oct 21, 2024
0 parents commit 26e8ab8
Show file tree
Hide file tree
Showing 10 changed files with 414 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set default behavior to automatically normalize line endings.
* text=auto
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.vsix
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
}
]
}
4 changes: 4 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 uncenter

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.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# vscode-tera

[Visual Studio Code](https://code.visualstudio.com/) extension & [TextMate](https://macromates.com/manual/en/language_grammars) grammar for the [Tera](https://keats.github.io/tera/) templating language.

## License

[MIT](LICENSE)
34 changes: 34 additions & 0 deletions language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"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": [
["{{", "}}"],
["{%", "%}"],
["{#", "#}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["%", "%"],
["#", "#"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["`", "`"]
],
// symbols that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["`", "`"]
]
}
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "tera",
"displayName": "Tera",
"description": "Syntax highlighting for Tera; a powerful, easy-to-use template language inspired by Jinja2 and Django templates.",
"version": "0.0.1",
"engines": {
"vscode": "^1.94.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [
{
"id": "tera",
"aliases": [
"Tera",
"tera"
],
"extensions": [
".tera"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "tera",
"scopeName": "source.tera",
"path": "./syntaxes/tera.tmLanguage.json"
}
]
}
}
266 changes: 266 additions & 0 deletions syntaxes/tera.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Tera",
"patterns": [
{
"begin": "{#-?",
"captures": {
"0": {
"name": "punctuation.definition.comment.tera"
}
},
"end": "-?#}",
"name": "comment.block.tera"
},
{
"begin": "{{-?",
"captures": {
"0": {
"name": "punctuation.definition.tera"
}
},
"end": "-?}}",
"name": "meta.scope.tera.expression",
"patterns": [
{
"include": "#expression"
}
]
},
{
"begin": "{%-?",
"captures": {
"0": {
"name": "punctuation.definition.tera"
}
},
"end": "-?%}",
"name": "meta.scope.tera.tag",
"patterns": [
{
"match": "\\b(if|else|elif|endif|for|continue|break|endfor|block|endblock|filter|endfilter|macro|endmacro|set|set_global|include|import|extends)\\b",
"name": "keyword.control.tera"
},
{
"begin": "(?<=\\b(if|elif|for|filter|macro|set|set_global|include|import|extends)\\b)\\s+",
"end": "(?=-?%})",
"patterns": [
{
"include": "#expression"
}
]
},
{
"begin": "(?<=\\b(block|endblock|filter|endmacro)\\b)\\s+",
"end": "(?=-?%})",
"patterns": [
{
"include": "#identifier"
}
]
}
]
},
{
"begin": "({%)\\s*(raw)\\s*(%})",
"captures": {
"1": {
"name": "punctuation.other.tera"
},
"2": {
"name": "keyword.control.tera"
},
"3": {
"name": "punctuation.other.tera"
}
},
"end": "({%)\\s*(endraw)\\s*(%})",
"name": "comment.block.tera.raw"
}
],
"repository": {
"identifier": {
"patterns": [
{
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]+)\\b",
"name": "variable.other.tera"
}
]
},
"expression": {
"patterns": [
{
"captures": {
"1": {
"name": "keyword.control.tera"
},
"2": {
"name": "keyword.control.tera"
},
"3": {
"name": "entity.name.function.tera"
}
},
"match": "\\s*\\b(is)\\s+(not\\s+)?(\\w+)\\b"
},
{
"match": "(\\+|\\-|\\*|/|%|~)",
"name": "keyword.operator.arithmetic.tera"
},
{
"captures": {
"1": {
"name": "keyword.operator.tera"
},
"2": {
"name": "support.function.builtin.tera"
},
"3": {
"name": "entity.name.function.tera"
}
},
"match": "(\\|)\\s*((lower|upper|wordcount|capitalize|replace|addslashes|slugify|title|trim|trim_start|trim_end|trim_start_matches|trim_end_matches|truncate|linebreaksbr|spaceless|indent|striptags|first|last|nth|join|length|reverse|sort|unique|slice|group_by|filter|map|concat|urlencode|urlencode_strict|abs|pluralize|round|filesizeformat|date|escape|escape_xml|safe|get|split|int|float|json_encode|as_str|default)|(\\w+))\\b"
},
{
"match": "\\b(loop|__tera_context)\\b",
"name": "variable.language.tera"
},
{
"include": "#identifier"
},
{
"captures": {
"1": {
"name": "punctuation.other.tera"
},
"2": {
"name": "variable.other.tera.attribute"
}
},
"match": "(\\.)(\\w+)"
},
{
"begin": "\\[",
"captures": {
"0": {
"name": "punctuation.other.tera"
}
},
"end": "\\]",
"patterns": [
{
"include": "#expression"
}
]
},
{
"begin": "\\(",
"captures": {
"0": {
"name": "punctuation.other.tera"
}
},
"end": "\\)",
"patterns": [
{
"include": "#expression"
}
]
},
{
"match": "(\\.|,|::)",
"name": "punctuation.other.tera"
},
{
"match": "(==|>=|<=|<|>|!=)",
"name": "keyword.operator.comparison.tera"
},
{
"match": "=",
"name": "keyword.operator.assignment.tera"
},
{
"name": "keyword.operator",
"match": "\\b(in|and|or|not|is)\\b"
},
{
"name": "constant.numeric",
"match": "[+-]?[0-9]+(\\.[0-9]+)?"
},
{
"name": "constant.language.boolean.tera",
"match": "\\b[Tt]rue|[Ff]alse\\b"
},
{
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.tera"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.tera"
}
},
"name": "string.quoted.double.tera",
"patterns": [
{
"include": "#string"
}
]
},
{
"begin": "'",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.tera"
}
},
"end": "'",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.tera"
}
},
"name": "string.quoted.single.tera",
"patterns": [
{
"include": "#string"
}
]
},
{
"begin": "`",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.tera"
}
},
"end": "`",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.tera"
}
},
"name": "string.quoted.other.tera",
"patterns": [
{
"include": "#string"
}
]
}
]
},
"string": {
"patterns": [
{
"match": "\\\\.",
"name": "constant.character.escape.tera"
}
]
}
},
"scopeName": "source.tera"
}
Loading

0 comments on commit 26e8ab8

Please sign in to comment.