From 21512af01ea77a1ee4bb0bcab129166ccda45b7c Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Mon, 8 Jan 2018 11:40:20 +0200 Subject: [PATCH 1/2] Add support for "keyfiles" to sublime-build syntax highlighting --- .../Main Keys (in-string).sublime-completions | 1 + .../Completions/Main Keys.sublime-completions | 1 + .../Sublime Text Build System.sublime-syntax | 24 +++++++++++++++++++ .../syntax_test_build_system.json | 9 +++++++ 4 files changed, 35 insertions(+) diff --git a/Package/Sublime Text Build System/Completions/Main Keys (in-string).sublime-completions b/Package/Sublime Text Build System/Completions/Main Keys (in-string).sublime-completions index 257042a6..3874c1c6 100644 --- a/Package/Sublime Text Build System/Completions/Main Keys (in-string).sublime-completions +++ b/Package/Sublime Text Build System/Completions/Main Keys (in-string).sublime-completions @@ -3,5 +3,6 @@ "completions": [ { "trigger": "selector\tmain key", "contents": "selector" }, { "trigger": "variants\tmain key", "contents": "variants" }, + { "trigger": "keyfiles\tmain key", "contents": "keyfiles" }, ] } diff --git a/Package/Sublime Text Build System/Completions/Main Keys.sublime-completions b/Package/Sublime Text Build System/Completions/Main Keys.sublime-completions index d5cfa899..a3f76827 100644 --- a/Package/Sublime Text Build System/Completions/Main Keys.sublime-completions +++ b/Package/Sublime Text Build System/Completions/Main Keys.sublime-completions @@ -3,5 +3,6 @@ "completions": [ { "trigger": "selector\tmain key", "contents": "\"selector\": \"$1\",$0" }, { "trigger": "variants\tmain key", "contents": "\"variants\": [\n\t$0\n]," }, + { "trigger": "keyfiles\tmain key", "contents": "\"keyfiles\": [\"$0\"]," }, ] } diff --git a/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax b/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax index 9efe146c..902f881b 100644 --- a/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax +++ b/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax @@ -47,6 +47,13 @@ contexts: 2: keyword.other.main.sublime-build 3: punctuation.definition.string.end.json set: [expect-variants-sequence-value, expect-colon] + - match: (")(keyfiles)(") + scope: meta.mapping.key.json meta.main-key.sublime-build string.quoted.double.json + captures: + 1: punctuation.definition.string.begin.json + 2: keyword.other.main.sublime-build + 3: punctuation.definition.string.end.json + set: [expect-keyfiles-sequence-value, expect-colon] - include: target-key - include: exec-args-key - include: platform-key @@ -375,6 +382,23 @@ contexts: pop: true - include: string-escape + expect-keyfiles-sequence-value: + - match: (?=\[) + set: [mapping-value-meta, keyfiles-sequence-pop] + - include: expect-sequence-rest + + keyfiles-sequence-pop: + - match: \[ + scope: punctuation.section.sequence.begin.json + set: + - meta_scope: meta.sequence.json meta.keyfiles.collection.sublime-build + - include: comments + - match: \] + scope: punctuation.section.sequence.end.json + pop: true + - match: (?=\S) + push: [in-sequence-expect-comma, Sublime JSON.sublime-syntax#expect-string] + comments: - include: Sublime JSON.sublime-syntax#comments diff --git a/Package/Sublime Text Build System/syntax_test_build_system.json b/Package/Sublime Text Build System/syntax_test_build_system.json index 3ab6a93f..3ccabd10 100644 --- a/Package/Sublime Text Build System/syntax_test_build_system.json +++ b/Package/Sublime Text Build System/syntax_test_build_system.json @@ -20,6 +20,15 @@ // ^^^^^^ string.unquoted.scope-segment.scope-selector // ^ punctuation.separator.scope-segments.scope-selector // ^^^^^^ string.unquoted.scope-segment.scope-selector + "keyfiles": ["Make"], +// ^^^^^^^^^^ meta.mapping.key.json meta.main-key.sublime-build string.quoted.double.json +// ^^^^^^^^ keyword.other.main.sublime-build +// ^ punctuation.separator.mapping.key-value.json +// ^^^^^^^^ meta.keyfiles.collection.sublime-build +// ^ punctuation.section.sequence.begin.json +// ^^^^^^ string.quoted.double.json +// ^ punctuation.section.sequence.end.json +// ^ meta.mapping.json meta.expect-comma.sublime punctuation.separator.mapping.pair.json - meta.keyfiles "other_key": "value", // ^^^^^^^^^^^ meta.mapping.key.json meta.main-key.sublime-build string.quoted.double.json From 46d97fd499e9721254995df098dcb000e89bd7ee Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Fri, 9 Feb 2018 16:52:58 +0200 Subject: [PATCH 2/2] Fix invalid scoping of valid `cancel` values in build systems --- .../Sublime Text Build System.sublime-syntax | 6 +++++- .../syntax_test_build_system.json | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax b/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax index 902f881b..04b777d6 100644 --- a/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax +++ b/Package/Sublime Text Build System/Sublime Text Build System.sublime-syntax @@ -93,7 +93,7 @@ contexts: 1: punctuation.definition.string.begin.json 2: keyword.other.main.sublime-build 3: punctuation.definition.string.end.json - set: [expect-command-name-value, expect-colon] + set: [expect-command-name-or-dict-value, expect-colon] exec-args-key: - match: (")(cmd)(") @@ -447,6 +447,10 @@ contexts: expect-command-name-value: - include: Sublime JSON.sublime-syntax#expect-command-name-value + expect-command-name-or-dict-value: + - include: Sublime JSON.sublime-syntax#command-name-pop + - include: expect-mapping-value + mapping-value-meta: - clear_scopes: 1 - meta_scope: meta.mapping.value.json diff --git a/Package/Sublime Text Build System/syntax_test_build_system.json b/Package/Sublime Text Build System/syntax_test_build_system.json index 3ccabd10..a65a1641 100644 --- a/Package/Sublime Text Build System/syntax_test_build_system.json +++ b/Package/Sublime Text Build System/syntax_test_build_system.json @@ -171,7 +171,14 @@ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.regexp.embedded.json-string }, }, - ] + ], + + "cancel": "cancel_build", +// ^^^^^^ keyword.other.main.sublime-build +// ^^^^^^^^^^^^ support.constant.command-name.sublime + "cancel": {"kill": true}, +// ^^^^^^ meta.mapping.key.json string.quoted.double.json +// ^^^^ constant.language.boolean.json } ,[]//fgfg