diff --git a/Package/Sublime Text Mousemap/Completions/Main Keys (in-string).sublime-completions b/Package/Sublime Text Mousemap/Completions/Main Keys (in-string).sublime-completions index df2bd229..52774a73 100644 --- a/Package/Sublime Text Mousemap/Completions/Main Keys (in-string).sublime-completions +++ b/Package/Sublime Text Mousemap/Completions/Main Keys (in-string).sublime-completions @@ -16,6 +16,11 @@ "details": "Command name", "kind": ["keyword", "k", "main"], }, + { + "trigger": "context", + "details": "Context restrictions", + "kind": ["keyword", "k", "main"], + }, { "trigger": "args", "details": "Command arguments", diff --git a/Package/Sublime Text Mousemap/Completions/Main Keys.sublime-completions b/Package/Sublime Text Mousemap/Completions/Main Keys.sublime-completions index 2d782b21..a4bf30e7 100644 --- a/Package/Sublime Text Mousemap/Completions/Main Keys.sublime-completions +++ b/Package/Sublime Text Mousemap/Completions/Main Keys.sublime-completions @@ -19,6 +19,12 @@ "details": "Command name", "kind": ["keyword", "k", "main"], }, + { + "trigger": "context", + "contents": "\"context\": [\n\t$0\n],", + "details": "Context restrictions", + "kind": ["keyword", "k", "main"], + }, { "trigger": "press_command", "contents": "\"press_command\": \"$1\",$0", diff --git a/Package/Sublime Text Mousemap/Sublime Text Mousemap.sublime-syntax b/Package/Sublime Text Mousemap/Sublime Text Mousemap.sublime-syntax index 19f3f8ea..5a998b83 100644 --- a/Package/Sublime Text Mousemap/Sublime Text Mousemap.sublime-syntax +++ b/Package/Sublime Text Mousemap/Sublime Text Mousemap.sublime-syntax @@ -60,6 +60,13 @@ contexts: 2: keyword.other.main.sublime-mousemap 3: punctuation.definition.string.end.json set: [expect-command-name-value, expect-colon] + - match: (")(context)(") + scope: meta.mapping.key.json meta.main-key.sublime-mousemap string.quoted.double.json + captures: + 1: punctuation.definition.string.begin.json + 2: keyword.other.main.sublime-keymap + 3: punctuation.definition.string.end.json + set: [in-mapping-expect-comma, expect-context-sequence-value, expect-colon] - match: (")((?:press_)?args)(") scope: meta.mapping.key.json meta.main-key.sublime-mousemap string.quoted.double.json captures: @@ -197,6 +204,10 @@ contexts: in-mapping-expect-comma: - include: Sublime JSON.sublime-syntax#in-mapping-expect-comma + expect-context-sequence-value: + # This means we have keymap suffixes in the scopes, but I'm lazy enough not to care + - include: Sublime Text Keymap.sublime-syntax#expect-context-sequence-value + mapping-value-meta: - clear_scopes: 1 # remove `meta.mapping.json` - meta_scope: meta.mapping.value.json diff --git a/Package/Sublime Text Mousemap/syntax_test_mousemap.json b/Package/Sublime Text Mousemap/syntax_test_mousemap.json index 51026622..3606c43d 100644 --- a/Package/Sublime Text Mousemap/syntax_test_mousemap.json +++ b/Package/Sublime Text Mousemap/syntax_test_mousemap.json @@ -101,6 +101,29 @@ // ^^ - invalid // ^ punctuation.separator.sequence.json + { + "context": [ +// ^^^^^^^^^ meta.mapping.key.json meta.main-key.sublime-mousemap string.quoted.double.json +// ^ punctuation.definition.string.begin.json +// ^^^^^^^ keyword.other.main.sublime-keymap +// ^ punctuation.definition.string.end.json +// ^ punctuation.separator.mapping.key-value.json +// ^ meta.keybinding-context-collection.sublime-keymap punctuation.section.sequence.begin.json + { "key": "group_has_multiselect", "operator": "equal", "operand": "" }, +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.keybinding-context-collection.sublime-keymap meta.keybinding-context.sublime-keymap meta.mapping +// ^ meta.mapping.json punctuation.section.mapping.begin.json +// ^^^^^ meta.mapping.key.json meta.context-key.sublime-keymap string.quoted.double.json +// ^ punctuation.definition.string.begin.json +// ^^^ support.function.context.sublime-keymap +// ^ punctuation.definition.string.end.json +// ^ meta.mapping.json punctuation.separator.mapping.key-value.json +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.context.key-value.key.other.sublime-keymap string.quoted.double.json +// ^ punctuation.definition.string.begin.json +// ^^^^^^^^^^^^^^^^^^^^^ storage.type.context.key-value.sublime-keymap +// ^ punctuation.definition.string.end.json +// (we assume the rest will be matched correctly and is separately tested in the keymap syntax) + ], + } {