|
| 1 | +[ |
| 2 | + // Auto-pair quotes |
| 3 | + { "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\"$0\""}, "context": |
| 4 | + [ |
| 5 | + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, |
| 6 | + { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, |
| 7 | + { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true }, |
| 8 | + { "key": "preceding_text", "operator": "regex_contains", "operand": "(?:[bfruBFRU]|[^'[:alnum:]_])$", "match_all": true }, |
| 9 | + { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double - punctuation.definition.string.end", "match_all": true }, |
| 10 | + { "key": "eol_selector", "operator": "equal", "operand": "source.python", "match_all": true } |
| 11 | + ] |
| 12 | + }, |
| 13 | + // Auto-pair single quotes |
| 14 | + { "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'$0'"}, "context": |
| 15 | + [ |
| 16 | + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, |
| 17 | + { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, |
| 18 | + { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true }, |
| 19 | + { "key": "preceding_text", "operator": "regex_contains", "operand": "(?:[bfruBFRU]|[^'[:alnum:]_])$", "match_all": true }, |
| 20 | + { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.single - punctuation.definition.string.end", "match_all": true }, |
| 21 | + { "key": "eol_selector", "operator": "equal", "operand": "source.python", "match_all": true } |
| 22 | + ] |
| 23 | + }, |
| 24 | + // Auto-pair curly brackets |
| 25 | + { "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context": |
| 26 | + [ |
| 27 | + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, |
| 28 | + { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, |
| 29 | + { "key": "following_text", "operator": "not_regex_contains", "operand": "^\\{", "match_all": true }, |
| 30 | + { "key": "selector", "operator": "equal", "operand": "meta.fstring.python", "match_all": true }, |
| 31 | + { "key": "selector", "operator": "equal", "operand": "string.quoted", "match_all": true } |
| 32 | + ] |
| 33 | + }, |
| 34 | + // Replace a '{|}' with '{{|' when typing within fstring |
| 35 | + { "keys": ["{"], "command": "run_macro_file", |
| 36 | + "args": {"name": "Packages/MagicPython/snippets/sublime/fstring_brace.sublime-macro"}, |
| 37 | + "context": |
| 38 | + [ |
| 39 | + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, |
| 40 | + { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, |
| 41 | + { "key": "preceding_text", "operator": "regex_contains", "operand": "\\{$", "match_all": true }, |
| 42 | + { "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true }, |
| 43 | + { "key": "selector", "operator": "equal", "operand": "meta.fstring.python", "match_all": true }, |
| 44 | + { "key": "selector", "operator": "equal", "operand": "constant.character.format.placeholder.other", "match_all": true } |
| 45 | + ] |
| 46 | + }, |
| 47 | +] |
0 commit comments