Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 40 additions & 22 deletions JavaScript/Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,71 @@
// Auto-pair backticks
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "(source.js, source.ts) - string" },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "selector", "operand": "source.js - source.js meta.string, source.jsx - source.jsx meta.string, source.ts - source.ts meta.string, source.tsx - source.tsx meta.string", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
]
},
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "(source.js, source.ts) - string" },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "operand": false, "match_all": true },
{ "key": "selector", "operand": "source.js - source.js meta.string, source.jsx - source.jsx meta.string, source.ts - source.ts meta.string, source.tsx - source.tsx meta.string", "match_all": true }
]
},
{ "keys": ["`"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.js, source.ts" },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true },
{ "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "selector", "operand": "meta.string.template.js - meta.string.template.js punctuation.definition.string.begin", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
]
},
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "string.quoted.other.js" },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "selector", "operand": "meta.string.template.js - meta.string.template.js punctuation.definition.string.begin", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "`$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true },
{ "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
]
},

// Add indented line in backticks
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "setting.auto_indent" },
{ "key": "selection_empty", "match_all": true },
{ "key": "selector", "operand": "meta.string.template.js", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "`$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
]
},
{ "keys": ["keypad_enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
[
{ "key": "setting.auto_indent" },
{ "key": "selection_empty", "match_all": true },
{ "key": "selector", "operand": "meta.string.template.js", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "`$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
]
},

// Auto-pair interpolation
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "string.quoted.other.js", "match_all": true },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "match_all": true },
{ "key": "selector", "operand": "meta.string.template.js", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\$$", "match_all": true }
]
},
{ "keys": ["$"], "command": "insert_snippet", "args": {"contents": "\\${${0:$SELECTION}}"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "string.quoted.other.js", "match_all": true },
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
{ "key": "setting.auto_match_enabled" },
{ "key": "selection_empty", "operand": false, "match_all": true },
{ "key": "selector", "operand": "meta.string.template.js", "match_all": true }
]
},
]
30 changes: 15 additions & 15 deletions JavaScript/JavaScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1238,62 +1238,62 @@ contexts:
- match: (css)\s*((\`){{trailing_wspace}}?)
captures:
1: variable.function.tagged-template.js
2: meta.string.js string.quoted.other.js
2: meta.string.template.js string.quoted.other.js
3: punctuation.definition.string.begin.js
embed: scope:source.css.js-template
embed_scope: meta.string.js source.css.embedded.js
embed_scope: meta.string.template.js source.css.embedded.js
escape: '{{leading_wspace}}?(\`)'
escape_captures:
0: meta.string.js string.quoted.other.js
0: meta.string.template.js string.quoted.other.js
1: punctuation.definition.string.end.js
pop: 1
- match: (html)\s*((\`){{trailing_wspace}}?)
captures:
1: variable.function.tagged-template.js
2: meta.string.js string.quoted.other.js
2: meta.string.template.js string.quoted.other.js
3: punctuation.definition.string.begin.js
embed: scope:text.html.js-template
embed_scope: meta.string.js text.html.embedded.js
embed_scope: meta.string.template.js text.html.embedded.js
escape: '{{leading_wspace}}?(\`)'
escape_captures:
0: meta.string.js string.quoted.other.js
0: meta.string.template.js string.quoted.other.js
1: punctuation.definition.string.end.js
pop: 1
- match: (js)\s*((\`){{trailing_wspace}}?)
captures:
1: variable.function.tagged-template.js
2: meta.string.js string.quoted.other.js
2: meta.string.template.js string.quoted.other.js
3: punctuation.definition.string.begin.js
embed: scope:source.js.js-template
embed_scope: meta.string.js source.js.embedded.js
embed_scope: meta.string.template.js source.js.embedded.js
escape: '{{leading_wspace}}?(\`)'
escape_captures:
0: meta.string.js string.quoted.other.js
0: meta.string.template.js string.quoted.other.js
1: punctuation.definition.string.end.js
pop: 1
- match: (json)\s*((\`){{trailing_wspace}}?)
captures:
1: variable.function.tagged-template.js
2: meta.string.js string.quoted.other.js
2: meta.string.template.js string.quoted.other.js
3: punctuation.definition.string.begin.js
embed: scope:source.json.js-template
embed_scope: meta.string.js source.json.embedded.js
embed_scope: meta.string.template.js source.json.embedded.js
escape: '{{leading_wspace}}?(\`)'
escape_captures:
0: meta.string.js string.quoted.other.js
0: meta.string.template.js string.quoted.other.js
1: punctuation.definition.string.end.js
pop: 1
- match: (?:({{identifier_name}})\s*)?(\`)
captures:
1: variable.function.tagged-template.js
2: meta.string.js string.quoted.other.js punctuation.definition.string.begin.js
2: meta.string.template.js string.quoted.other.js punctuation.definition.string.begin.js
set: literal-string-template-content

literal-string-template-content:
- meta_include_prototype: false
- meta_content_scope: meta.string.js string.quoted.other.js
- meta_content_scope: meta.string.template.js string.quoted.other.js
- match: \`
scope: meta.string.js string.quoted.other.js punctuation.definition.string.end.js
scope: meta.string.template.js string.quoted.other.js punctuation.definition.string.end.js
pop: 1
- include: string-interpolations
- include: string-content
Expand Down
Loading