Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Oct 27, 2024
2 parents 49ee3cd + 9a1746b commit 2dfbb0d
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"caption": "Preferences: Liquid Key Bindings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/Liquid/Default.sublime-keymap",
"user_file": "${packages}/User/Default ($platform).sublime-keymap",
"default": "[\n\t${0}\n]\n"
}
}
]
183 changes: 183 additions & 0 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
[
// Auto-pair braces also in front of , : ; so starting embeddings in CSS properties and values works well.

{
"keys": ["{"],
"command": "insert_snippet",
"args": {
"contents": "{$0}"
},
"context": [
{ "key": "selector", "operand": "meta.template.liquid - meta.embedded.liquid - meta.interpolation.liquid - meta.template.liquid string" },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:[ \t\\)\\]\\},:;]|$)", "match_all": true }
]
},

// Auto-pair braces also in front of closing ' and " in strings

{
"keys": ["{"],
"command": "insert_snippet",
"args": {
"contents": "{$0}"
},
"context": [
{ "key": "selector", "operand": "meta.template.liquid string" },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:[ \t\\)\\]\\}\"',:;]|$)", "match_all": true }
]
},

// Bindings for inserting and removing statement block.

// Expand {|} to {% | %} when % is pressed
{
"keys": ["%"],
"command": "insert_snippet",
"args": {
"contents": "% ${0} %"
},
"context": [
{ "key": "selector", "operand": "meta.template.liquid - meta.embedded.liquid - meta.interpolation.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "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.embedded.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "{%$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^%}", "match_all": true }
]
},
// Expand {%|%} to {% | %} when space is pressed
{
"keys": [" "],
"command": "insert_snippet",
"args": {
"contents": " ${0} "
},
"context": [
{ "key": "selector", "operand": "meta.embedded.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "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" }
]
},
"context": [
{ "key": "selector", "operand": "meta.embedded.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "{% $", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^ %}", "match_all": true }
]
},

// Bindings for inserting and removing expression block.

// Expand {|} to {{ | }} when { is pressed
{
"keys": ["{"],
"command": "insert_snippet",
"args": {
"contents": "{ ${0} }"
},
"context": [
{ "key": "selector", "operand": "meta.template.liquid - meta.embedded.liquid - meta.interpolation.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "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.interpolation.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "{{$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^}}", "match_all": true }
]
},
// Expand {{|}} to {{ | }} when space is pressed
{
"keys": [" "],
"command": "insert_snippet",
"args": {
"contents": " ${0} "
},
"context": [
{ "key": "selector", "operand": "meta.interpolation.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "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" }
]
},
"context": [
{ "key": "selector", "operand": "meta.interpolation.liquid" },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "{{ $", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^ }}", "match_all": true }
]
},
{
"keys": ["enter"],
"command": "run_macro_file",
"args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"},
"context": [
{ "key": "selector", "operand": "meta.template.liquid - source.liquid, meta.embedded.liquid punctuation.section.embedded.begin" },
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "%\\}\\s*$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\{%", "match_all": true }
]
}
]
28 changes: 28 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"id": "preferences",
"children": [
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children": [
{
"caption": "Liquid",
"children": [
{
"caption": "Key Bindings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/Liquid/Default.sublime-keymap",
"user_file": "${packages}/User/Default ($platform).sublime-keymap",
"default": "[\n\t${0}\n]\n"
}
}
]
}
]
}
]
}
]

0 comments on commit 2dfbb0d

Please sign in to comment.