Sublime Forum

[SOLVED] Multiple selectors in keymap

#1

I’m working with the Behat Completions plugin. The plugin works fine if using the “Behat” plugin for syntax highlighting, but doesn’t work at all when using Behat features (another syntax highlighter for the same language that works a little better). I’ve determined the issue is because the Behat Completions plugin is hardcoded to use a specific scope, which I understand is just a string that is a more specific description of the language the syntax highlighter uses.

The keymap looks like this:

{ "key": "selector", "operator": "equal", "operand": "feature.behat" }

I can substitue feature.behat with source.feature.generic and the completions plugin works great. But I’d like to submit pull request so that this plugin will work with either syntax highlighter. I’ve tried various combos, and none have seemed to work. The furthest I’ve gotten was:

{ "key": "selector", "operator": "regex_match", "operand": "(feature\\.behat|source\\.feature\\.generic)" },

I also tried it with “match_all”: true but it won’t match on both. It will work with the first, but the second is unrecognized.

What’s the proper methodology for making a keymap work on two syntaxes?

0 Likes

#2

The “equal” operator for selector appears to have some special handling. Try something like:

{ "key": "selector", "operator": "equal", "operand": "(feature.behat, source.feature.generic)", "match_all": true }

It also supports the minus sign to subtract scopes.

0 Likes

#3

Awesome, that worked perfectly. Thank you!

0 Likes