emmetio / sublime-text-plugin

The essential toolkit for web-developers
https://emmet.io
MIT License
253 stars 29 forks source link

Can't override key binding for tab emmet_expand_abbreviation #146

Open japalo opened 3 years ago

japalo commented 3 years ago

I'm currently trying to disable emmet_expand_abbreviation if sublimes autocomplete is visible using this snippet in my user key bindings:

[
    // Tab key handler for single cursor
    {
        "keys": ["tab"],
        "command": "emmet_expand_abbreviation",
        "args": { "tab": true },
        "context": [
            {
                "operand": false,
                "operator": "equal",
                "match_all": true,
                "key": "auto_complete_visible"
            },
            { "key": "emmet_abbreviation" },
            { "key": "emmet_tab_expand" },
            { "key": "num_selections", "operand": 1 }
        ]
    },

    // Tab key handler for multiple cursors
    {
        "keys": ["tab"],
        "command": "emmet_expand_abbreviation",
        "context": [
            {
                "operand": false,
                "operator": "equal",
                "match_all": true,
                "key": "auto_complete_visible"
            },
            { "key": "emmet_activation_scope" },
            { "key": "emmet_multicursor_tab_expand" },
            { "key": "num_selections", "operator": "not_equal", "operand": 1 }
        ]
    }
]

What i expected is that the default key binding is inactivated, and mine are applied, but this doesn't happen. Not sure if I'm doing it wrong though so support is also welcome :) The new version of emmet kinda slowed my workflow a bit. I've been working with abbreviation expansion only if autocomplete isn't visible and nothing is selected for many years so it would be nice to be able to customize the key mappings.

Refer to this gif to better understand the issue: Dec-10-2020 10-13-57

sergeche commented 3 years ago

In Sublime Text, you can’t unset shortcuts provided by plugins.

I’m not sure which goal you’re trying to achieve. New Emmet doesn’t require autocomplete, it automatically tracks abbreviations you are typing (displayed as subtle underline). Tracked abbreviation can be expanded with Tab key or reseted with Esc key. If you’re not happy with this behaviour, there’s a number of ways to disable tracking and expand by specific keybinding for specific syntax: https://github.com/emmetio/sublime-text-plugin#disable-abbreviation-capturing

japalo commented 3 years ago

I want to achieve to avoid expanding abbreviation if sublimes OOTB auto complete i open. If it's open, the Tab key should not expand abbreviation. I don't want to unset the shortcut, i want to extend it. What i am asking for here is either ways to extend the shortcut, or at least a setting for the plugin where I can disable the expand abbreviation if autocomplete is open.

japalo commented 3 years ago

I also think that this semi viral gist worked great: https://gist.github.com/wesbos/2bb4a6998635df97c748 I've used this (unsupported) key binds for many years so it's really hard to work with the new version.

I hope it's doable to get this change for the newest version of the plugin.