Skip to content

Commit

Permalink
Merge pull request #2 from deathaxe/pr/st4152-rewrite
Browse files Browse the repository at this point in the history
Rewrite for ST4152+
  • Loading branch information
cedeber authored Aug 19, 2024
2 parents 1cc7dcd + 3c0ac56 commit 6c56b23
Show file tree
Hide file tree
Showing 31 changed files with 1,316 additions and 108 deletions.
10 changes: 10 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"caption": "Preferences: Mustache Key Bindings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/Mustache/Default.sublime-keymap",
"default": "[\n\t${0}\n]\n"
}
}
]
52 changes: 52 additions & 0 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
// Expand {|} to {{ | }} when { is pressed
{
"keys": [" "],
"command": "insert_snippet",
"args": { "contents": " ${0} " },
"context": [
{ "key": "selector", "operand": "meta.template.mustache" },
{ "key": "setting.auto_match_enabled", "operand": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "{{[!$#^/$>]?$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "}}$", "match_all": true }
]
},
// Reduce {{|}} to | when backspace is pressed
{
"keys": ["backspace"],
"command": "chain",
"args": {
"commands": [
{"command": "left_delete" },
{"command": "right_delete" },
{"command": "left_delete" },
{"command": "right_delete" }
]
},
"context": [
{ "key": "selector", "operand": "meta.template.mustache meta.embedded" },
{ "key": "setting.auto_match_enabled", "operand": true },
{ "key": "selection_empty", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "{{$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^}}", "match_all": true }
]
},
// Reduce {{! | }} to {{!|}} or {{ | }} to {{|}} when backspace is pressed
{
"keys": ["backspace"],
"command": "chain",
"args": {
"commands": [
{"command": "left_delete" },
{"command": "right_delete" }
]
},
"context": [
{ "key": "selector", "operand": "meta.template.mustache meta.embedded" },
{ "key": "setting.auto_match_enabled", "operand": true },
{ "key": "selection_empty", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "{{[!$#^/&>]? $", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^ }}", "match_all": true }
]
}
]
6 changes: 6 additions & 0 deletions Snippets/comment.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<snippet>
<content><![CDATA[${TM_TEMPLATE_START}! ${0:comment} ${TM_TEMPLATE_END}]]></content>
<tabTrigger>!</tabTrigger>
<scope>meta.template.mustache</scope>
<description>Mustache Comment</description>
</snippet>
10 changes: 10 additions & 0 deletions Snippets/else.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
${TM_TEMPLATE_START}^ ${1:variable} ${TM_TEMPLATE_END}
${TM_TEMPLATE_INDENT}$0
${TM_TEMPLATE_START}/ ${1:variable} ${TM_TEMPLATE_END}
]]></content>
<tabTrigger>else</tabTrigger>
<scope>meta.template.mustache</scope>
<description>Mustache Inverted Section</description>
</snippet>
10 changes: 10 additions & 0 deletions Snippets/if.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
${TM_TEMPLATE_START}# ${1:variable} ${TM_TEMPLATE_END}
${TM_TEMPLATE_INDENT}$0
${TM_TEMPLATE_START}/ ${1:variable} ${TM_TEMPLATE_END}
]]></content>
<tabTrigger>if</tabTrigger>
<scope>meta.template.mustache</scope>
<description>Mustache Section</description>
</snippet>
6 changes: 6 additions & 0 deletions Snippets/partial.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<snippet>
<content><![CDATA[${TM_TEMPLATE_START}> ${1:partial} ${TM_TEMPLATE_END}]]></content>
<tabTrigger>inc</tabTrigger>
<scope>meta.template.mustache</scope>
<description>Mustache Partial</description>
</snippet>
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<snippet>
<content><![CDATA[
{{{ ${1:variable} }}}
]]></content>
<content><![CDATA[{{{ ${1:variable} }}}]]></content>
<tabTrigger>let</tabTrigger>
<scope>meta.template.mustache</scope>
<description>Mustache Unescaped Variable</description>
<scope>embedding.mustache</scope>
</snippet>
6 changes: 6 additions & 0 deletions Snippets/variable.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<snippet>
<content><![CDATA[${TM_TEMPLATE_START} ${1:variable} ${TM_TEMPLATE_END}]]></content>
<tabTrigger>var</tabTrigger>
<scope>meta.template.mustache</scope>
<description>Mustache Escaped Variable</description>
</snippet>
43 changes: 43 additions & 0 deletions Syntaxes/CSS/CSS (Mustache).sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: CSS (Mustache)
scope: source.css.mustache
version: 2

extends: Packages/CSS/CSS.sublime-syntax

file_extensions:
- css.mustache
- mustache.css

variables:

# CSS overrides

ident_start: (?:{{nmstart}}|{{mustache_tag_start}})

# required until ST4173
selector_begin: (?={{selector_start}}|{{mustache_tag_start}})
# required until ST4173
nested_selector_begin: (?={{nested_selector_start}}|{{mustache_tag_start}})

tag_name_begin: (?=[[:alpha:]]|{{mustache_tag_start}})

# CSS (Mustache) variables

mustache_tag_start: '{{'
mustache_tag_end: '}}'

contexts:
main:
- meta_prepend: true
- meta_scope: meta.template.mustage

prototype:
- meta_prepend: true
- include: Text (Mustache).sublime-syntax

string-content:
- meta_prepend: true
- include: Text (Mustache).sublime-syntax#interpolations
41 changes: 41 additions & 0 deletions Syntaxes/CSS/Comments.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>scope</key>
<string>
source.css.mustache,
text.html.mustache source.css.embedded
</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>{{! </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END</string>
<key>value</key>
<string> }}</string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_START_2</string>
<key>value</key>
<string>/* </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END_2</string>
<key>value</key>
<string> */</string>
</dict>
</array>
</dict>
</dict>
</plist>
23 changes: 23 additions & 0 deletions Syntaxes/CSS/Snippet Variables.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>
source.css.mustache,
text.html.mustache source.css.embedded
</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<!-- Syntax specific block snippet content indentation -->
<key>name</key>
<string>TM_TEMPLATE_INDENT</string>
<key>value</key>
<string></string>
</dict>
</array>
</dict>
</dict>
</plist>
38 changes: 38 additions & 0 deletions Syntaxes/HTML/Comments.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>scope</key>
<string>text.html.mustache</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>{{! </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END</string>
<key>value</key>
<string> }}</string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_START_2</string>
<key>value</key>
<string><![CDATA[<!-- ]]></string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END_2</string>
<key>value</key>
<string><![CDATA[ -->]]></string>
</dict>
</array>
</dict>
</dict>
</plist>
Loading

0 comments on commit 6c56b23

Please sign in to comment.