├── icon.png ├── enable.gif ├── .vscode └── launch.json ├── CHANGELOG.md ├── antlers.configuration.json ├── package.json ├── README.md └── syntaxes └── antlers.json /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addisonhall/ahdesign.antlers/HEAD/icon.png -------------------------------------------------------------------------------- /enable.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/addisonhall/ahdesign.antlers/HEAD/enable.gif -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 2 | * Updated for Statamic 3! Big thanks to [@lachieh](https://github.com/lachieh). See more at [the pull request](https://github.com/addisonhall/ahdesign.antlers/pull/7). 3 | 4 | ## 0.0.4 5 | * Setting the language id and grammar language to "html" so that HTML intellisense and Emmet will be available 6 | 7 | ## 0.0.3 8 | * Added note to README regarding use of beautifier (thank you @subpixelch) 9 | 10 | ## 0.0.2 11 | * Added link to GitHub repo 12 | 13 | ## 0.0.1 14 | * Porting my Atom package over to VS Code 15 | -------------------------------------------------------------------------------- /antlers.configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "blockComment": [ "{{#", "#}}" ] 4 | }, 5 | "brackets": [ 6 | ["{", "}"], 7 | ["[", "]"], 8 | ["(", ")"] 9 | ], 10 | "autoClosingPairs": [ 11 | ["{", "}"], 12 | ["[", "]"], 13 | ["(", ")"], 14 | ["\"", "\""], 15 | ["'", "'"] 16 | ], 17 | "surroundingPairs": [ 18 | ["{", "}"], 19 | ["[", "]"], 20 | ["(", ")"], 21 | ["\"", "\""], 22 | ["'", "'"] 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-antlers", 3 | "displayName": "Statamic Antlers Templates", 4 | "description": "Antlers Template Language Syntax Highlighter", 5 | "version": "0.0.4", 6 | "icon": "icon.png", 7 | "publisher": "ahdesign", 8 | "engines": { 9 | "vscode": "^1.0.0" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/addisonhall/ahdesign.antlers" 14 | }, 15 | "keywords": [ 16 | "statamic", 17 | "antlers", 18 | "template" 19 | ], 20 | "categories": [ 21 | "Programming Languages" 22 | ], 23 | "contributes": { 24 | "languages": [ 25 | { 26 | "id": "html", 27 | "aliases": [ 28 | "HTML (Statamic Antlers)", 29 | "antlers" 30 | ], 31 | "extensions": [ 32 | ".html", 33 | ".htm", 34 | ".xhtml" 35 | ], 36 | "configuration": "./antlers.configuration.json" 37 | } 38 | ], 39 | "grammars": [ 40 | { 41 | "language": "html", 42 | "scopeName": "text.html.statamic", 43 | "path": "./syntaxes/antlers.json" 44 | } 45 | ] 46 | }, 47 | "__metadata": { 48 | "id": "24891be9-dd0f-4757-b3ed-37b7d841e0cf", 49 | "publisherDisplayName": "ahdesign", 50 | "publisherId": "807e9432-95bb-45bc-953b-9da19405f5c3" 51 | } 52 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | "Antlers" Statamic syntax highlighting for Visual Studio Code 2 | ============================================================= 3 | 4 | Big update! 5 | ----------- 6 | 7 | A huge thanks to [lachieh](https://github.com/lachieh) for all of the new goodies, including **support for Statamic 3**! Find out more [in the pull request](https://github.com/addisonhall/ahdesign.antlers/pull/7). 8 | 9 | About "Antlers" for VS Code 10 | --------------------------- 11 | 12 | This started as a weekend project to bring Statamic tag syntax highlighting to Sublime Text. I pulled a lot of the information for this from this ExpressionEngine bundle: https://github.com/fcgrx/ExpressionEngine2-Sublime-Text-3-Bundle and looking at this documentation: http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html. ~~In all honesty, I still don't understand why much of the syntax works. I was able to port the Sublime Text version over to Atom.~~ I have a much better understanding of how grammars work now, so future versions should work much better. 13 | 14 | I called this Antlers because it was just fun... I mean, heck... everything about Statamic is fun. 15 | 16 | What is Statamic? 17 | ----------------- 18 | 19 | Statamic (http://statamic.com) is a no-database, flat-file content management system that is far more capable than you would ever expect it to be. It's crazy fun to develop with as well. 20 | 21 | How to use 22 | ---------- 23 | 24 | This extension now essentially replaces the HTML syntax so that Antlers will take advantage of HTML intellisense and Emmet, so I recommend only enabling it for Statamic projects. You can do this via the "Enable (Workspace)" option. 25 | 26 | ![Enable (Workspace)](enable.gif) 27 | 28 | Note that you won't have to select Antlers as your language -- if enabled, it will automatically kick in for any .html, .htm, or .xhtml file. 29 | 30 | If you use a beautifier in VSC 31 | ------------------------------ 32 | 33 | Update your VSC settings, p.e.: 34 | 35 | ``` 36 | "beautify.language": { 37 | "html": [ 38 | "htm", 39 | "html", 40 | "antlers" 41 | ] 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /syntaxes/antlers.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileTypes": [ 3 | "antlers.html", 4 | "html", 5 | "htm", 6 | "xhtml" 7 | ], 8 | "name": "Antlers (Statamic Syntax)", 9 | "scopeName": "text.html.statamic", 10 | "foldingStartMarker": "{{(\\s?)", 11 | "foldingStopMarker": "(\\s?)}}", 12 | "injections": { 13 | "text.html.statamic - (meta.embedded | meta.tag | comment.block.statamic), L:(text.html.statamic meta.tag - (comment.block.statamic | meta.embedded.statamic))": { 14 | "patterns": [ 15 | { 16 | "include": "#statamic-comments" 17 | }, 18 | { 19 | "include": "#statamic-overall-tags" 20 | }, 21 | { 22 | "comment": "This is set to use XHTML standards, but you can change that by changing .strict to .basic for HTML standards", 23 | "include": "text.html.basic" 24 | } 25 | ] 26 | } 27 | }, 28 | "repository": { 29 | "statamic-comments": { 30 | "begin": "{{#", 31 | "end": "#}}", 32 | "name": "comment.block.statamic" 33 | }, 34 | "statamic-overall-tags": { 35 | "begin": "{{(\\s?)", 36 | "end": "(\\s?)}}", 37 | "name": "meta.embedded.block.statamic", 38 | "patterns": [ 39 | { 40 | "include": "#statamic-tag-addon-builtin" 41 | }, 42 | { 43 | "include": "#statamic-tag-parameter-variable" 44 | }, 45 | { 46 | "include": "#statamic-tag-conditional" 47 | }, 48 | { 49 | "include": "#tag-stuff" 50 | } 51 | ] 52 | }, 53 | "statamic-tag-addon-builtin": { 54 | "match": "(\\b(404|\/?asset(:)?|\/?assets(:)?|\/?cache|\/?can:cp:([a-zA-Z0-9-_:]+)|\/?collection(:([a-zA-Z0-9-_:]+))?|control_panel_edit_url|count|current_date|date_groups|dump|\/?email_form|\/?entries(:)?(listing|pagination|map|previous|next|meld)?|exists|\/?foreach(:([a-zA-Z0-9-_:]+))?|get:[a-zA-Z0-9-_\/\\:]+|\/?get_content(:([a-zA-Z0-9-_:]+))?|\/?get_files(:([a-zA-Z0-9-_:]+))?|get_post:[a-zA-Z0-9-_:]+|get_value:[a-zA-Z0-9-_:]+|glide(:batch)?|\/?in:[a-zA-Z0-9-_:]+|\/?is:[a-zA-Z0-9-_:]+|\/?items|link|\/?locales(:([a-zA-Z0-9-_:]+))?|\/?location(:(map_listing|map_url))?|log(:(debug|info|warn|error|fatal))?|login|login_form|logout|logout_url|\/?loop|markdown(:indent)?|\/?member(:(forgot_password_form|listing|pagination|profile|profile_form|register_form|reset_password_form))?|mix|\/?nav(:(exists|count|breadcrumbs))?|oauth(:([a-zA-Z0-9-_:]+))?|\/?obfuscate|old:[a-zA-Z0-9-_\\-:]+|\/?pages(:(listing|next|previous|meld))?|path|post:[a-zA-Z0-9-_:]+|\/?parent:[a-zA-Z0-9-_:]+|partial:[a-zA-Z0-9-_\/\\:]+|\/?protect:(password_form)|redirect|\/?relate:[a-zA-Z0-9-_:]+|route:[a-zA-Z0-9-_:]+|\/?search:results|section(:([a-zA-Z0-9-_:]+))?|session(:([a-zA-Z0-9-_:]+))?|svg|switch|\/?taxonomy:[a-zA-Z0-9-_:]+|\/?taxonomy:listing|theme(:([a-zA-Z0-9-_:]+))?|trans(:([a-zA-Z0-9-_:]+))?|transform|\/?user(:(can|forgot_password_form|in|is|login_form|logout|logout_url|profile|register_form|reset_password_form))?|\/?users|\/?var\\b(:([a-zA-Z0-9-_:]+))?|yield(:([a-zA-Z0-9-_:]+))?)\\b)", 55 | "captures": { 56 | "1": { 57 | "patterns": [{ 58 | "match": "(\/?[a-zA-Z0-9-_]+(:cp)?)((:)([a-zA-Z0-9-_\/\\:]+))?", 59 | "captures": { 60 | "1": { 61 | "name": "support.class.builtin.tag.statamic" 62 | }, 63 | "4": { 64 | "name": "punctuation.definition.parameters.begin.statamic" 65 | }, 66 | "5": { 67 | "name": "variable.parameter.statamic" 68 | } 69 | } 70 | }] 71 | } 72 | } 73 | }, 74 | "statamic-tag-parameter-variable": { 75 | "match": "(:?(\\S+?)(=)('|\")([^\\4]*?)(\\4))", 76 | "captures": { 77 | "1": { 78 | "patterns": [ 79 | { 80 | "match": ":(\\S+?)(=)('|\")(.*?)(\\3)", 81 | "captures": { 82 | "1": { 83 | "name": "entity.other.attribute-name", 84 | "patterns": [{ 85 | "match": "\\b(absolute|action|add|allow_request_redirect|allow_request_return|ampersand_list|as|ascii|at|attr|backspace|bcc|between|blur|brightness|by|cache_bust|camelize|cc|cdata|ceil|center_point|class|clusters|collapse|collapse_whitespace|collection|conditions|console_log|container|contains|contains_all|contains_any|contrast|count|count_substring|crop|current|current_first|dashify|days_ago|decode|depth|deslugify|destination|divide|dl|do|dont_use|dpr|dump|email|ends_with|ensure_left|ensure_right|entities|error_redirect|exclude|explode|ext|extension|favicon|field|fields|file|file_date|file_size|filename|filter|first|fit|flatten|flip|floor|folder|folders_only|for|form|format|format_localized|formset|from|full_urls|gamma|gravatar|greyscale|group|group_by|group_by_date|groups|handle|has_lower_case|has_upper_case|height|honeypot|hours_ago|id|image|in|include_content|include_entries|include_home|index|insert|is|is_after|is_alpha|is_alphanumeric|is_before|is_between|is_empty|is_future|is_json|is_leap_year|is_lowercase|is_numberwang|is_numeric|is_past|is_today|is_uppercase|is_weekday|is_weekend|is_yesterday|join|key|last|lcfirst|length|limit|link|links|locale|locate_with|logged_in_redirect|lower|macro|mailto|map_id|markdown|match|max_depth|member|message|min_count|minutes_ago|mod|months_ago|msg_footer|msg_header|multiply|name|nl2br|not_folder|not_from|not_in|obfuscate|obfuscate_email|offset|ol|open_popup|orient|page|paginate|param|partial|permission|pixelate|plural|pos_x|pos_y|precision|provider|quality|query|query_scope|ratio|rawurlencode|read_time|recursive|redirect|redirects|regex_replace|relative|remove_left|remove_right|repeat|replace|required|reset_return|reset_url|response|return|reverse|role|roles|rotate|round|safe_truncate|sanitize|scope|seconds_ago|segment|sentence_list|sharpen|show_future|show_hidden|show_past|show_published|show_unpublished|shuffle|since|singular|slugify|smartypants|sort|sort_by|sort_dir|specifically|square|src|starts_with|strip_tags|subject|substr|subtract|sum|supplement_data|surround|swap_case|tag|taxonomy|textile|tidy|times|title|to|to_json|to_spaces|to_tabs|trim|truncate|type|ucfirst|ul|underscored|unique|until|upper|upsize|url|urldecode|urlencode|use|use_context|username|version|watermark|weeks_ago|what|widont|width|word_count|wrap|years_ago|zoom)\\b", 86 | "name": "support.function.attribute.statamic" 87 | }] 88 | }, 89 | "2": { 90 | "name": "keyword.operator.assignment.statamic" 91 | }, 92 | "3": { 93 | "name": "punctuation.definition.parameters.begin.quote.double.statamic" 94 | }, 95 | "4": { 96 | "patterns": [{"include": "#expression-valid"}] 97 | }, 98 | "5": { 99 | "name": "punctuation.definition.parameters.end.quote.double.statamic" 100 | } 101 | } 102 | }, 103 | { 104 | "match": "([^:]+?)(=)(('|\")(.*?)(\\4))", 105 | "captures": { 106 | "1": { 107 | "name": "entity.other.attribute-name", 108 | "patterns": [{ 109 | "match": "\\b(absolute|action|add|allow_request_redirect|allow_request_return|ampersand_list|as|ascii|at|attr|backspace|bcc|between|blur|brightness|by|cache_bust|camelize|cc|cdata|ceil|center_point|class|clusters|collapse|collapse_whitespace|collection|conditions|console_log|container|contains|contains_all|contains_any|contrast|count|count_substring|crop|current|current_first|dashify|days_ago|decode|depth|deslugify|destination|divide|dl|do|dont_use|dpr|dump|email|ends_with|ensure_left|ensure_right|entities|error_redirect|exclude|explode|ext|extension|favicon|field|fields|file|file_date|file_size|filename|filter|first|fit|flatten|flip|floor|folder|folders_only|for|form|format|format_localized|formset|from|full_urls|gamma|gravatar|greyscale|group|group_by|group_by_date|groups|handle|has_lower_case|has_upper_case|height|honeypot|hours_ago|id|image|in|include_content|include_entries|include_home|index|insert|is|is_after|is_alpha|is_alphanumeric|is_before|is_between|is_empty|is_future|is_json|is_leap_year|is_lowercase|is_numberwang|is_numeric|is_past|is_today|is_uppercase|is_weekday|is_weekend|is_yesterday|join|key|last|lcfirst|length|limit|link|links|locale|locate_with|logged_in_redirect|lower|macro|mailto|map_id|markdown|match|max_depth|member|message|min_count|minutes_ago|mod|months_ago|msg_footer|msg_header|multiply|name|nl2br|not_folder|not_from|not_in|obfuscate|obfuscate_email|offset|ol|open_popup|orient|page|paginate|param|partial|permission|pixelate|plural|pos_x|pos_y|precision|provider|quality|query|query_scope|ratio|rawurlencode|read_time|recursive|redirect|redirects|regex_replace|relative|remove_left|remove_right|repeat|replace|required|reset_return|reset_url|response|return|reverse|role|roles|rotate|round|safe_truncate|sanitize|scope|seconds_ago|segment|sentence_list|sharpen|show_future|show_hidden|show_past|show_published|show_unpublished|shuffle|since|singular|slugify|smartypants|sort|sort_by|sort_dir|specifically|square|src|starts_with|strip_tags|subject|substr|subtract|sum|supplement_data|surround|swap_case|tag|taxonomy|textile|tidy|times|title|to|to_json|to_spaces|to_tabs|trim|truncate|type|ucfirst|ul|underscored|unique|until|upper|upsize|url|urldecode|urlencode|use|use_context|username|version|watermark|weeks_ago|what|widont|width|word_count|wrap|years_ago|zoom)\\b", 110 | "name": "support.function.attribute.statamic" 111 | }] 112 | }, 113 | "2": { 114 | "name": "keyword.operator.assignment.statamic" 115 | }, 116 | "3": { 117 | "patterns" : [ 118 | { "include": "#statamic-string-single-quoted"}, 119 | { "include": "#statamic-string-double-quoted"} 120 | ] 121 | } 122 | } 123 | } 124 | ] 125 | } 126 | } 127 | }, 128 | "statamic-string-interpolation-expression": { 129 | "begin": "{", 130 | "end": "}", 131 | "patterns": [{ "include": "#expression-valid" }] 132 | }, 133 | "statamic-tag-native-variable": { 134 | "match": "(\\G|\\s|\\b)(_is_draft|_is_hidden|_site_name|_site_url|recursive\\schildren|alt|basename|\/?children|collection|content|count|current_uri|current_url|date|date_group|datestamp|email_sent|environment|error|\/?errors|expired|extension|field_errors:[a-zA-Z0-9-_:]+|file|filename|first|get|get_post|grouped_date|has_entries|has_next|has_previous|homepage|id|index|is_[a-zA-Z0-9-_:]+|is_admin|is_current|is_entry|is_image|is_page|is_parent|is_published|is_\\[role\\]|in_\\[group\\]|last_modified_instance|last_modified_timestamp|last_modified|last_segment|last|layout_content|locale|logged_in|name|next_page|next|no_results|now|old_values:[a-zA-Z0-9-_:]+|page_url|paginate|parent|path|permalink|post|prev|previous_page|previous|response_code|results|search_score|segment_[0-9]+|site_url|size_b|size_bytes|size_gb|size_gigabytes|size_kb|size_kilobytes|size_mb|size_megabytes|size|slug|success|taxonomy_name|taxonomy_slug|theme_path|title|total_found|total_results|url_invalid|url|username|zero_index)\\b(?![\\=\\-\\:])", 135 | "captures": { 136 | "2": { 137 | "name": "variable.language.statamic" 138 | } 139 | } 140 | }, 141 | "statamic-variable": { 142 | "match": "(\/?\\w+)(:)?(\\w+)?", 143 | "captures": { 144 | "1": { 145 | "name": "variable.other.statamic" 146 | }, 147 | "2": { 148 | "name": "keyword.operator.other.statamic" 149 | }, 150 | "3": { 151 | "name": "variable.other.property.statamic" 152 | } 153 | } 154 | }, 155 | "statamic-var-modifiers": { 156 | "match": "(\\s)?(\\|)(\\s)?(\\w+((:([a-zA-Z0-9-_/-@]+)){1,2})?|((-|\\+|\\*|/|\\^|\\%):(\\d*)?\\.?(\\d+)))+", 157 | "captures": { 158 | "2": { 159 | "name": "keyword.operator.other.statamic" 160 | }, 161 | "4": { 162 | "name": "support.function.statamic" 163 | } 164 | } 165 | }, 166 | "statamic-tag-conditional": { 167 | "match": "(\/?else|\/?elseif|\/?if|\/?unless|endif|endunless|unlesselse)", 168 | "name": "keyword.control.statamic" 169 | }, 170 | "statamic-tag-operator": { 171 | "match": "(\\(|\\)|or|OR|and|AND|&&|<=|>=|<>|<|>|=|!=|==|===|!==|~|\\|\\|)", 172 | "name": "keyword.operator.logical.statamic" 173 | }, 174 | "statamic-constant-language": { 175 | "match": "(\\G|\\s|\\b)(true|TRUE|false|FALSE|yes|YES|no|NO)\\s", 176 | "captures": { 177 | "2": { 178 | "name": "constant.language.statamic" 179 | } 180 | } 181 | }, 182 | "statamic-constant-numbers": { 183 | "match": "(\\d*)?\\.?(\\d+)", 184 | "name": "constant.numeric.statamic" 185 | }, 186 | "statamic-modifier-pipe": { 187 | "match": "(\\|)", 188 | "name": "keyword.operator.other.statamic" 189 | }, 190 | "statamic-not-operator": { 191 | "match": "(\\s|^)(!)", 192 | "captures": { 193 | "2": { 194 | "name": "keyword.operator.other.statamic" 195 | } 196 | } 197 | }, 198 | "statamic-string-double-quoted": { 199 | "begin": "\"", 200 | "end": "\"", 201 | "name": "string.quoted.double.statamic", 202 | "patterns": [{ "include": "#statamic-string-interpolation-expression" }] 203 | }, 204 | "statamic-string-single-quoted": { 205 | "begin": "'", 206 | "end": "'", 207 | "name": "string.quoted.single.statamic", 208 | "patterns": [{ "include": "#statamic-string-interpolation-expression" }] 209 | }, 210 | "expression-valid": { 211 | "patterns": [ 212 | { 213 | "include": "#statamic-constant-numbers" 214 | }, 215 | { 216 | "include": "#statamic-constant-language" 217 | }, 218 | { 219 | "include": "#statamic-tag-native-variable" 220 | }, 221 | { 222 | "include": "#statamic-variable" 223 | }, 224 | { 225 | "include": "#statamic-var-modifiers" 226 | } 227 | ] 228 | }, 229 | "tag-stuff": { 230 | "patterns": [ 231 | { 232 | "include": "#statamic-constant-numbers" 233 | }, 234 | { 235 | "include": "#statamic-constant-language" 236 | }, 237 | { 238 | "include": "#statamic-tag-operator" 239 | }, 240 | { 241 | "include": "#statamic-not-operator" 242 | }, 243 | { 244 | "include": "#statamic-tag-native-variable" 245 | }, 246 | { 247 | "include": "#statamic-variable" 248 | }, 249 | { 250 | "include": "#statamic-var-modifiers" 251 | }, 252 | { 253 | "include": "#statamic-string-double-quoted" 254 | }, 255 | { 256 | "include": "#statamic-string-single-quoted" 257 | } 258 | ] 259 | } 260 | } 261 | } 262 | --------------------------------------------------------------------------------