From 81d4f7a340fdf542533ae8af78c3dab39dca7ff0 Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Sun, 31 Jan 2021 17:53:35 +0530 Subject: [PATCH 1/6] Add highlighting support for the platform key in sublime-commands file. This commit adds support for highlighting the platform key in sublime-commands file. Just used the contexts available in sublime-menu syntax file. --- .../Sublime Text Commands.sublime-syntax | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax index 0b49c4a2..db253b79 100644 --- a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax +++ b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax @@ -60,6 +60,13 @@ contexts: 2: keyword.other.main.sublime-commands 3: punctuation.definition.string.end.json set: [expect-mapping-value, expect-colon] + - match: (")(platform)(") + scope: meta.mapping.key.json meta.main-key.sublime-commands string.quoted.double.json + captures: + 1: punctuation.definition.string.begin.json + 2: keyword.other.main.sublime-commands + 3: punctuation.definition.string.end.json + set: [expect-platform-string-value, expect-colon] - match: (")(\w*)(") scope: meta.mapping.key.json meta.main-key.sublime-commands string.quoted.double.json captures: @@ -68,6 +75,33 @@ contexts: 3: punctuation.definition.string.end.json set: [expect-any-value, expect-colon] + expect-platform-string-value: + - match: (?=") + set: [mapping-value-meta, platform-name-string-pop] + - include: expect-string-rest + + platform-name-string-pop: + - match: (\")(!)?(Windows|Linux|OSX)(\") + scope: meta.platform-name.sublime-commands string.quoted.double.json + captures: + 1: punctuation.definition.string.begin.json + 2: keyword.operator.logical.sublime-commands + 3: support.constant.command-name.sublime-commands + 4: punctuation.definition.string.end.json + pop: true + - match: \" # probably illegal command name + scope: punctuation.definition.string.begin.json + set: + - meta_scope: meta.platform-name.sublime-commands string.quoted.double.json + - meta_content_scope: invalid.illegal.invalid-command.sublime-commands + - match: \" + scope: punctuation.definition.string.end.json + pop: true + - include: string-escape + - match: $\n? + scope: invalid.illegal.unclosed-string.json + pop: true + expect-command-name-value: - include: Sublime JSON.sublime-syntax#expect-command-name-value @@ -106,3 +140,9 @@ contexts: expect-key-rest: - include: Sublime JSON.sublime-syntax#expect-key-rest + + mapping-value-meta: + - clear_scopes: 1 + - meta_scope: meta.mapping.value.json + - match: '' + pop: true From b91395eb54ed7b6a922a05f9e3b9986a09799721 Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Sun, 31 Jan 2021 17:56:58 +0530 Subject: [PATCH 2/6] Add completions for the platform names in sublime-commands file. This commit adds completions for the platform names in sublime-commands file. Just copied the one used for menu files. --- .../Platform Names.sublime-completions | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Package/Sublime Text Commands/Completions/Platform Names.sublime-completions diff --git a/Package/Sublime Text Commands/Completions/Platform Names.sublime-completions b/Package/Sublime Text Commands/Completions/Platform Names.sublime-completions new file mode 100644 index 00000000..4fef03b1 --- /dev/null +++ b/Package/Sublime Text Commands/Completions/Platform Names.sublime-completions @@ -0,0 +1,17 @@ +{ + "scope": "meta.platform-name.sublime-commands", + "completions": [ + { + "trigger": "Linux", + "kind": ["snippet", "p", "Platform"], + }, + { + "trigger": "OSX", + "kind": ["snippet", "p", "Platform"], + }, + { + "trigger": "Windows", + "kind": ["snippet", "p", "Platform"], + }, + ] +} From 2f013255bbc5a454c0d20cd93c74bd6e188903a5 Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Sun, 31 Jan 2021 18:05:08 +0530 Subject: [PATCH 3/6] chore: Fix issues due to missing contexts. --- .../Sublime Text Commands.sublime-syntax | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax index db253b79..c6f814cb 100644 --- a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax +++ b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax @@ -114,6 +114,12 @@ contexts: expect-colon: - include: Sublime JSON.sublime-syntax#expect-colon + expect-string-rest: + - include: Sublime JSON.sublime-syntax#expect-string-rest + + string-escape: + - include: Sublime JSON.sublime-syntax#string-escape + expect-string-value: - include: Sublime JSON.sublime-syntax#expect-string-value From b1e75680e2b686dfbb8ddf3c5c66f6dd49f84fcb Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Tue, 2 Feb 2021 10:07:39 +0530 Subject: [PATCH 4/6] Chore: Address issues raised in review comments (Part 1) Add tests for the new platform key addition. --- .../Sublime Text Commands/syntax_test_commands.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Package/Sublime Text Commands/syntax_test_commands.json b/Package/Sublime Text Commands/syntax_test_commands.json index 72629705..230e93d9 100644 --- a/Package/Sublime Text Commands/syntax_test_commands.json +++ b/Package/Sublime Text Commands/syntax_test_commands.json @@ -25,7 +25,7 @@ // ^^^^^ meta.mapping.key.json meta.main-key.sublime-commands string.quoted.double.json // ^^^ - keyword.other.main.sublime-commands // ^^^^^ meta.mapping.value.json string.quoted.double.json - "args": {"setting": "word_wrap"} + "args": {"setting": "word_wrap"}, // ^^^^^^ meta.mapping.key.json meta.main-key.sublime-commands string.quoted.double.json // ^^^^ keyword.other.main.sublime-commands // ^ punctuation.separator.mapping.key-value.json @@ -35,6 +35,16 @@ // ^^^^^^^^^ meta.mapping.value.json meta.mapping.key.json string.quoted.double.json // ^ punctuation.separator.mapping.key-value.json // ^^^^^^^^^^^ meta.mapping.value.json meta.mapping.value.json string.quoted.double.json + "platform": "!Windows" +// ^^^^^^^^^^ meta.mapping.key.json meta.main-key.sublime-commands string.quoted.double.json +// ^ punctuation.definition.string.begin.json +// ^^^^^^^^ keyword.other.main.sublime-commands +// ^ punctuation.separator.mapping.key-value.json +// ^^^^^^^^^^ meta.mapping.value.json meta.platform-name.sublime-commands string.quoted.double.json +// ^ punctuation.definition.string.begin.json +// ^ keyword.operator.logical.sublime-commands +// ^^^^^^^ support.constant.command-name.sublime-commands +// ^ punctuation.definition.string.end.json }, abc From 14e25d48aaf77e6f089056e2c22c8bfeb91f15b7 Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Tue, 2 Feb 2021 10:09:07 +0530 Subject: [PATCH 5/6] Chore: Address issues raised in review comments (Part 2) Remove non needed comments from command & menu syntax. --- .../Sublime Text Commands/Sublime Text Commands.sublime-syntax | 2 +- Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax index c6f814cb..abbeaa20 100644 --- a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax +++ b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax @@ -89,7 +89,7 @@ contexts: 3: support.constant.command-name.sublime-commands 4: punctuation.definition.string.end.json pop: true - - match: \" # probably illegal command name + - match: \" scope: punctuation.definition.string.begin.json set: - meta_scope: meta.platform-name.sublime-commands string.quoted.double.json diff --git a/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax b/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax index c0a0d796..712beb92 100644 --- a/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax +++ b/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax @@ -136,7 +136,7 @@ contexts: 3: support.constant.command-name.sublime-menu 4: punctuation.definition.string.end.json pop: true - - match: \" # probably illegal command name + - match: \" scope: punctuation.definition.string.begin.json set: - meta_scope: meta.platform-name.sublime-menu string.quoted.double.json From 71db961671439cf835e08f946f9d4e1729550d32 Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Wed, 3 Feb 2021 09:36:17 +0530 Subject: [PATCH 6/6] Chore: Address issues raised in review comments (Part 3) Correct incorrect scopes for command & menu syntax. --- .../Sublime Text Commands/Sublime Text Commands.sublime-syntax | 2 +- Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax index abbeaa20..9d71d17b 100644 --- a/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax +++ b/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax @@ -93,7 +93,7 @@ contexts: scope: punctuation.definition.string.begin.json set: - meta_scope: meta.platform-name.sublime-commands string.quoted.double.json - - meta_content_scope: invalid.illegal.invalid-command.sublime-commands + - meta_content_scope: invalid.illegal.invalid-platform.sublime-commands - match: \" scope: punctuation.definition.string.end.json pop: true diff --git a/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax b/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax index 712beb92..969294e4 100644 --- a/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax +++ b/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax @@ -140,7 +140,7 @@ contexts: scope: punctuation.definition.string.begin.json set: - meta_scope: meta.platform-name.sublime-menu string.quoted.double.json - - meta_content_scope: invalid.illegal.invalid-command.sublime-menu + - meta_content_scope: invalid.illegal.invalid-platform.sublime-menu - match: \" scope: punctuation.definition.string.end.json pop: true