Skip to content

Commit

Permalink
Mousemap: Add support for context key
Browse files Browse the repository at this point in the history
Was added in build 4149.

Closes #388
  • Loading branch information
FichteFoll committed May 6, 2023
1 parent 54384c0 commit 212ffc7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions Package/Sublime Text Mousemap/Sublime Text Mousemap.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions Package/Sublime Text Mousemap/syntax_test_mousemap.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)
],
}

{

Expand Down

0 comments on commit 212ffc7

Please sign in to comment.