-pair double quotes
    // - not after escape \| -> \"|
    // - not after quote "| -> ""|
    // - after string modifiers: f| -> f"|"
    // - in front of dots: |.join() -> "|".join()
    // - in front of commas: |, -> "|",
    // - in front of colons: |: -> "|":
    // - in front of semicolons: |; -> "|";
    { "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\"$0\""}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python - string.quoted.double" },
            { "key": "selection_empty", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "(?i:^|[^\"\\w\\\\]|\\b[bfru]+)$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|\\.|,|:|;|$)", "match_all": true }
        ]
    },

    // Suppress default auto-pairing bindings to avoid unwanted interference
    { "keys": ["'"], "command": "insert", "args": {"characters": "'"}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python - string.quoted.single" },
            { "key": "selection_empty", "match_all": true }
        ]
    },
    // Auto-pair single quotes
    // - not after escape \| -> \"|
    // - not after quote '| -> ''|
    // - after string modifiers: f| -> f"|"
    // - in front of dots: |.join() -> "|".join()
    // - in front of commas: |, -> "|",
    // - in front of colons: |: -> "|":
    // - in front of semicolons: |; -> "|";
    { "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'$0'"}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python - string.quoted.single" },
            { "key": "selection_empty", "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "(?i:^|[^'\\w\\\\]|\\b[bfru]+)$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|\\.|,|:|;|$)", "match_all": true }
        ]
    },

    // Suppress default auto-pairing bindings to avoid unwanted interference
    { "keys": ["("], "command": "insert", "args": {"characters": "("}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python" },
            { "key": "selection_empty", "match_all": true }
        ]
    },
    // Auto-pair parens: | -> (|)
    { "keys": ["("], "command": "insert_snippet", "args": {"contents": "($0)"}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python" },
            { "key": "selection_empty", "match_all": true },
            { "key": "preceding_text", "operator": "not_regex_contains", "operand": "\\\\$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|}|,|;|'|\"|$)", "match_all": true }
        ]
    },

    // Suppress default auto-pairing bindings to avoid unwanted interference
    { "keys": ["["], "command": "insert", "args": {"characters": "["}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python" },
            { "key": "selection_empty", "match_all": true }
        ]
    },
    // Auto-pair brackets: | -> [|]
    { "keys": ["["], "command": "insert_snippet", "args": {"contents": "[$0]"}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python" },
            { "key": "selection_empty", "match_all": true },
            { "key": "preceding_text", "operator": "not_regex_contains", "operand": "\\\\$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|}|,|;|'|\"|$)", "match_all": true }
        ]
    },

    // Suppress default auto-pairing bindings to avoid unwanted interference
    { "keys": ["{"], "command": "insert", "args": {"characters": "{"}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python" },
            { "key": "selection_empty", "match_all": true }
        ]
    },
    // Auto-pair braces: | -> {|},
    { "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
        [
            { "key": "setting.auto_match_enabled" },
            { "key": "selector", "operand": "source.python" },
            { "key": "selection_empty", "match_all": true },
            { "key": "preceding_text", "operator": "not_regex_contains", "operand": "\\\\$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|}|,|;|'|\"|$)", "match_all": true }
        ]
    },
]
PK