Skip to content

Commit

Permalink
Refactor Syntax
Browse files Browse the repository at this point in the history
This commit...

1. introduces common `meta.template.twig` applied scope accross Text/HTML/JS/CSS
2. adjusts snippet selectors
3. adds some helper key bindings
4. applies syntax specific toggle comment rules to apply Twig comments
   by default but retain original syntax's block comment as variant 2.
5. renames contexts to use hyphens as subword-separators
6. reorders contexts following lessons learned from Jinja and other template
   syntaxes
7. apply `meta.embedded` to tags and `source.twig` to their content.
8. fix various smaller highlighting bugs
  • Loading branch information
deathaxe committed Oct 19, 2024
1 parent b839025 commit a0ad157
Show file tree
Hide file tree
Showing 48 changed files with 3,638 additions and 1,563 deletions.
Original file line number Diff line number Diff line change
@@ -1,380 +1,326 @@
{
"scope": "meta.function.filter.twig, meta.statement.apply.twig",
"scope": "source.twig meta.filter",
"completions": [
{
"trigger": "abs",
"contents": "abs",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the absolute value.",
},
{
"trigger": "batch",
"contents": "batch",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Batches items by returning a list of lists with the given number of items.",
},
{
"trigger": "capitalize",
"contents": "capitalize",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Capitalizes a value.",
},
{
"trigger": "column",
"contents": "column",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the values from a single column in the input array.",
},
{
"trigger": "convert_encoding",
"contents": "convert_encoding",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Converts a string from one encoding to another.",
},
{
"trigger": "country_name",
"contents": "country_name",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the country name given its ISO-3166 two-letter code.",
},
{
"trigger": "currency_name",
"contents": "currency_name",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the currency name given its three-letter code.",
},
{
"trigger": "currency_symbol",
"contents": "currency_symbol",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the currency symbol given its three-letter code.",
},
{
"trigger": "data_uri",
"contents": "data_uri",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Generates a URL using the data scheme as defined in RFC 2397.",
},
{
"trigger": "date",
"contents": "date",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats a date to a given format.",
},
{
"trigger": "date_modify",
"contents": "date_modify",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Modifies a date with a given modifier string.",
},
{
"trigger": "default",
"contents": "default",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the passed default value if the value is undefined or empty.",
},
{
"trigger": "escape",
"contents": "escape",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Escapes a string using strategies that depend on the context.",
},
{
"trigger": "filter",
"contents": "filter",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Filters elements of a sequence or a mapping using an arrow function.",
},
{
"trigger": "first",
"contents": "first",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the first element of a sequence, a mapping, or a string.",
},
{
"trigger": "format",
"contents": "format",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats a given string by replacing the placeholders.",
},
{
"trigger": "format_currency",
"contents": "format_currency",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats a number as a currency.",
},
{
"trigger": "format_date",
"contents": "format_date",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats a date.",
},
{
"trigger": "format_datetime",
"contents": "format_datetime",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats a date time.",
},
{
"trigger": "format_number",
"contents": "format_number",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats a number.",
},
{
"trigger": "format_time",
"contents": "format_time",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats the given time.",
},
{
"trigger": "html_to_markdown",
"contents": "html_to_markdown",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Converts a block of HTML to Markdown.",
},
{
"trigger": "inline_css",
"contents": "inline_css",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Inlines CSS styles in HTML documents.",
},
{
"trigger": "inky_to_html",
"contents": "inky_to_html",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Processes an inky email template.",
},
{
"trigger": "join",
"contents": "join",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns a string which is the concatenation of the items of a sequence.",
},
{
"trigger": "json_encode",
"contents": "json_encode",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the JSON representation of a value.",
},
{
"trigger": "keys",
"contents": "keys",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the keys of an array.",
},
{
"trigger": "language_name",
"contents": "language_name",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the language name given its two-letter code.",
},
{
"trigger": "last",
"contents": "last",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the last element of a sequence, a mapping, or a string.",
},
{
"trigger": "length",
"contents": "length",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the number of items of a sequence, mapping or a string.",
},
{
"trigger": "locale_name",
"contents": "locale_name",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the locale name given its two-letter code.",
},
{
"trigger": "lower",
"contents": "lower",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Converts a value to lowercase.",
},
{
"trigger": "map",
"contents": "map",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Applies an arrow function to the elements of a sequence or a mapping.",
},
{
"trigger": "markdown_to_html",
"contents": "markdown_to_html",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Converts a block of Markdown to HTML.",
},
{
"trigger": "merge",
"contents": "merge",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Merges an array with another array.",
},
{
"trigger": "nl2br",
"contents": "nl2br",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Inserts HTML line breaks before all newlines in a string.",
},
{
"trigger": "number_format",
"contents": "number_format",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats numbers.",
},
{
"trigger": "raw",
"contents": "raw",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Marks the value as being <b>safe</b>.",
},
{
"trigger": "reduce",
"contents": "reduce",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Iteratively reduces a sequence or a mapping to a single value using an arrow function.",
},
{
"trigger": "replace",
"contents": "replace",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Formats a given string by replacing the placeholders.",
},
{
"trigger": "reverse",
"contents": "reverse",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Reverses a sequence, a mapping, or a string.",
},
{
"trigger": "round",
"contents": "round",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Rounds a number to a given precision.",
},
{
"trigger": "slice",
"contents": "slice",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Extracts a slice of a sequence, a mapping, or a string.",
},
{
"trigger": "slug",
"contents": "slug",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Transforms a given string into another string that only includes safe ASCII characters.",
},
{
"trigger": "sort",
"contents": "sort",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Sorts an array.",
},
{
"trigger": "spaceless",
"contents": "spaceless",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Remove whitespace between HTML tags.",
},
{
"trigger": "split",
"contents": "split",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Splits a string by the given delimiter and returns a list of strings.",
},
{
"trigger": "striptags",
"contents": "striptags",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Strips SGML/XML tags and replace adjacent whitespace by one space.",
},
{
"trigger": "timezone_name",
"contents": "timezone_name",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns the timezone name given a timezone identifier.",
},
{
"trigger": "title",
"contents": "title",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Returns a titlecased version of the value.",
},
{
"trigger": "trim",
"contents": "trim",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Strips whitespace from beginning & end of a string.",
},
{
"trigger": "u",
"contents": "u",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Wraps a text in a Unicode object.",
},
{
"trigger": "upper",
"contents": "upper",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Converts a value to uppercase.",
},
{
"trigger": "url_encode",
"contents": "url_encode",
"kind": ["namespace", "f", "Twig Filter"],
"annotation": "Twig Filter",
"details": "Percent encodes a given string as URL segment or an array.",
Expand Down
Loading

0 comments on commit a0ad157

Please sign in to comment.