diff --git a/extensions/gitsyntax/.vscodeignore b/extensions/gitsyntax/.vscodeignore index 77ab386fc7d..30c5d19d6c3 100644 --- a/extensions/gitsyntax/.vscodeignore +++ b/extensions/gitsyntax/.vscodeignore @@ -1 +1,2 @@ -test/** \ No newline at end of file +test/** +build/** \ No newline at end of file diff --git a/extensions/gitsyntax/build/update-grammars.js b/extensions/gitsyntax/build/update-grammars.js new file mode 100644 index 00000000000..268157d43f8 --- /dev/null +++ b/extensions/gitsyntax/build/update-grammars.js @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +var updateGrammar = require('../../../build/npm/update-grammar'); + +updateGrammar.update('textmate/git.tmbundle', 'Syntaxes/Git%20Commit%20Message.tmLanguage', './syntaxes/git-commit.tmLanguage.json'); +updateGrammar.update('textmate/git.tmbundle', 'Syntaxes/Git%20Rebase%20Message.tmLanguage', './syntaxes/git-rebase.tmLanguage.json'); +updateGrammar.update('textmate/diff.tmbundle', 'Syntaxes/Diff.plist', './syntaxes/diff.tmLanguage.json'); + + + + + diff --git a/extensions/gitsyntax/package.json b/extensions/gitsyntax/package.json index d01893d002a..306713af50b 100644 --- a/extensions/gitsyntax/package.json +++ b/extensions/gitsyntax/package.json @@ -11,7 +11,7 @@ "Other" ], "scripts": { - "update-grammar": "node ../../build/npm/update-grammar.js textmate/git.tmbundle Syntaxes/Git%20Commit%20Message.tmLanguage ./syntaxes/git-commit.tmLanguage.json Syntaxes/Git%20Rebase%20Message.tmLanguage ./syntaxes/git-rebase.tmLanguage.json" + "update-grammar": "node ./build/update-grammars.js" }, "contributes": { "languages": [ @@ -66,7 +66,7 @@ { "language": "diff", "scopeName": "source.diff", - "path": "./syntaxes/diff.tmLanguage" + "path": "./syntaxes/diff.tmLanguage.json" } ], "configurationDefaults": { diff --git a/extensions/gitsyntax/syntaxes/diff.tmLanguage b/extensions/gitsyntax/syntaxes/diff.tmLanguage deleted file mode 100644 index e71adc69fd1..00000000000 --- a/extensions/gitsyntax/syntaxes/diff.tmLanguage +++ /dev/null @@ -1,268 +0,0 @@ - - - - - fileTypes - - patch - diff - rej - - firstLineMatch - (?x)^ - (===\ modified\ file - |==== \s* // .+ \s - \s .+ \s+ ==== - |Index:\ - |---\ [^%\n] - |\*\*\*.*\d{4}\s*$ - |\d+(,\d+)* (a|d|c) \d+(,\d+)* $ - |diff\ --git\ - |commit\ [0-9a-f]{40}$ - ) - keyEquivalent - ^~D - name - Diff - patterns - - - captures - - 1 - - name - punctuation.definition.separator.diff - - - match - ^((\*{15})|(={67})|(-{3}))$\n? - name - meta.separator.diff - - - match - ^\d+(,\d+)*(a|d|c)\d+(,\d+)*$\n? - name - meta.diff.range.normal - - - captures - - 1 - - name - punctuation.definition.range.diff - - 2 - - name - meta.toc-list.line-number.diff - - 3 - - name - punctuation.definition.range.diff - - - match - ^(@@)\s*(.+?)\s*(@@)($\n?)? - name - meta.diff.range.unified - - - captures - - 3 - - name - punctuation.definition.range.diff - - 4 - - name - punctuation.definition.range.diff - - 6 - - name - punctuation.definition.range.diff - - 7 - - name - punctuation.definition.range.diff - - - match - ^(((\-{3}) .+ (\-{4}))|((\*{3}) .+ (\*{4})))$\n? - name - meta.diff.range.context - - - match - ^diff --git a/.*$\n? - name - meta.diff.header.git - - - match - ^diff (-|\S+\s+\S+).*$\n? - name - meta.diff.header.command - - - captures - - 4 - - name - punctuation.definition.from-file.diff - - 6 - - name - punctuation.definition.from-file.diff - - 7 - - name - punctuation.definition.from-file.diff - - - match - (^(((-{3}) .+)|((\*{3}) .+))$\n?|^(={4}) .+(?= - )) - name - meta.diff.header.from-file - - - captures - - 2 - - name - punctuation.definition.to-file.diff - - 3 - - name - punctuation.definition.to-file.diff - - 4 - - name - punctuation.definition.to-file.diff - - - match - (^(\+{3}) .+$\n?| (-) .* (={4})$\n?) - name - meta.diff.header.to-file - - - captures - - 3 - - name - punctuation.definition.inserted.diff - - 6 - - name - punctuation.definition.inserted.diff - - - match - ^(((>)( .*)?)|((\+).*))$\n? - name - markup.inserted.diff - - - captures - - 1 - - name - punctuation.definition.changed.diff - - - match - ^(!).*$\n? - name - markup.changed.diff - - - captures - - 3 - - name - punctuation.definition.deleted.diff - - 6 - - name - punctuation.definition.deleted.diff - - - match - ^(((<)( .*)?)|((-).*))$\n? - name - markup.deleted.diff - - - begin - ^(#) - captures - - 1 - - name - punctuation.definition.comment.diff - - - comment - Git produces unified diffs with embedded comments" - end - \n - name - comment.line.number-sign.diff - - - match - ^index [0-9a-f]{7,40}\.\.[0-9a-f]{7,40}.*$\n? - name - meta.diff.index.git - - - captures - - 1 - - name - punctuation.separator.key-value.diff - - 2 - - name - meta.toc-list.file-name.diff - - - match - ^Index(:) (.+)$\n? - name - meta.diff.index - - - match - ^Only in .*: .*$\n? - name - meta.diff.only-in - - - scopeName - source.diff - uuid - 7E848FF4-708E-11D9-97B4-0011242E4184 - - diff --git a/extensions/gitsyntax/syntaxes/diff.tmLanguage.json b/extensions/gitsyntax/syntaxes/diff.tmLanguage.json new file mode 100644 index 00000000000..e0d60de1081 --- /dev/null +++ b/extensions/gitsyntax/syntaxes/diff.tmLanguage.json @@ -0,0 +1,168 @@ +{ + "information_for_contributors": [ + "This file has been converted from https://github.com/textmate/diff.tmbundle/blob/master/Syntaxes/Diff.plist", + "If you want to provide a fix or improvement, please create a pull request against the original repository.", + "Once accepted there, we are happy to receive an update request." + ], + "version": "https://github.com/textmate/diff.tmbundle/commit/0593bb775eab1824af97ef2172fd38822abd97d7", + "fileTypes": [ + "patch", + "diff", + "rej" + ], + "firstLineMatch": "(?x)^\n\t\t(===\\ modified\\ file\n\t\t|==== \\s* // .+ \\s - \\s .+ \\s+ ====\n\t\t|Index:\\ \n\t\t|---\\ [^%\\n]\n\t\t|\\*\\*\\*.*\\d{4}\\s*$\n\t\t|\\d+(,\\d+)* (a|d|c) \\d+(,\\d+)* $\n\t\t|diff\\ --git\\ \n\t\t|commit\\ [0-9a-f]{40}$\n\t\t)", + "keyEquivalent": "^~D", + "name": "Diff", + "patterns": [ + { + "captures": { + "1": { + "name": "punctuation.definition.separator.diff" + } + }, + "match": "^((\\*{15})|(={67})|(-{3}))$\\n?", + "name": "meta.separator.diff" + }, + { + "match": "^\\d+(,\\d+)*(a|d|c)\\d+(,\\d+)*$\\n?", + "name": "meta.diff.range.normal" + }, + { + "captures": { + "1": { + "name": "punctuation.definition.range.diff" + }, + "2": { + "name": "meta.toc-list.line-number.diff" + }, + "3": { + "name": "punctuation.definition.range.diff" + } + }, + "match": "^(@@)\\s*(.+?)\\s*(@@)($\\n?)?", + "name": "meta.diff.range.unified" + }, + { + "captures": { + "3": { + "name": "punctuation.definition.range.diff" + }, + "4": { + "name": "punctuation.definition.range.diff" + }, + "6": { + "name": "punctuation.definition.range.diff" + }, + "7": { + "name": "punctuation.definition.range.diff" + } + }, + "match": "^(((\\-{3}) .+ (\\-{4}))|((\\*{3}) .+ (\\*{4})))$\\n?", + "name": "meta.diff.range.context" + }, + { + "match": "^diff --git a/.*$\\n?", + "name": "meta.diff.header.git" + }, + { + "match": "^diff (-|\\S+\\s+\\S+).*$\\n?", + "name": "meta.diff.header.command" + }, + { + "captures": { + "4": { + "name": "punctuation.definition.from-file.diff" + }, + "6": { + "name": "punctuation.definition.from-file.diff" + }, + "7": { + "name": "punctuation.definition.from-file.diff" + } + }, + "match": "(^(((-{3}) .+)|((\\*{3}) .+))$\\n?|^(={4}) .+(?= - ))", + "name": "meta.diff.header.from-file" + }, + { + "captures": { + "2": { + "name": "punctuation.definition.to-file.diff" + }, + "3": { + "name": "punctuation.definition.to-file.diff" + }, + "4": { + "name": "punctuation.definition.to-file.diff" + } + }, + "match": "(^(\\+{3}) .+$\\n?| (-) .* (={4})$\\n?)", + "name": "meta.diff.header.to-file" + }, + { + "captures": { + "3": { + "name": "punctuation.definition.inserted.diff" + }, + "6": { + "name": "punctuation.definition.inserted.diff" + } + }, + "match": "^(((>)( .*)?)|((\\+).*))$\\n?", + "name": "markup.inserted.diff" + }, + { + "captures": { + "1": { + "name": "punctuation.definition.changed.diff" + } + }, + "match": "^(!).*$\\n?", + "name": "markup.changed.diff" + }, + { + "captures": { + "3": { + "name": "punctuation.definition.deleted.diff" + }, + "6": { + "name": "punctuation.definition.deleted.diff" + } + }, + "match": "^(((<)( .*)?)|((-).*))$\\n?", + "name": "markup.deleted.diff" + }, + { + "begin": "^(#)", + "captures": { + "1": { + "name": "punctuation.definition.comment.diff" + } + }, + "comment": "Git produces unified diffs with embedded comments\"", + "end": "\\n", + "name": "comment.line.number-sign.diff" + }, + { + "match": "^index [0-9a-f]{7,40}\\.\\.[0-9a-f]{7,40}.*$\\n?", + "name": "meta.diff.index.git" + }, + { + "captures": { + "1": { + "name": "punctuation.separator.key-value.diff" + }, + "2": { + "name": "meta.toc-list.file-name.diff" + } + }, + "match": "^Index(:) (.+)$\\n?", + "name": "meta.diff.index" + }, + { + "match": "^Only in .*: .*$\\n?", + "name": "meta.diff.only-in" + } + ], + "scopeName": "source.diff", + "uuid": "7E848FF4-708E-11D9-97B4-0011242E4184" +} \ No newline at end of file diff --git a/extensions/gitsyntax/test/colorize-fixtures/example.diff b/extensions/gitsyntax/test/colorize-fixtures/example.diff new file mode 100644 index 00000000000..256b719212f --- /dev/null +++ b/extensions/gitsyntax/test/colorize-fixtures/example.diff @@ -0,0 +1,7 @@ +diff --git a/helloworld.txt b/helloworld.txt +index e4f37c4..557db03 100644 +--- a/helloworld.txt ++++ b/helloworld.txt +@@ -1 +1 @@ +-Hello world ++Hello World \ No newline at end of file diff --git a/extensions/gitsyntax/test/colorize-results/example_diff.json b/extensions/gitsyntax/test/colorize-results/example_diff.json new file mode 100644 index 00000000000..07ec9f737b5 --- /dev/null +++ b/extensions/gitsyntax/test/colorize-results/example_diff.json @@ -0,0 +1,167 @@ +[ + { + "c": "diff --git a/helloworld.txt b/helloworld.txt", + "t": "source.diff meta.diff.header.git", + "r": { + "dark_plus": "meta.diff.header: #569CD6", + "light_plus": "meta.diff.header: #000080", + "dark_vs": "meta.diff.header: #569CD6", + "light_vs": "meta.diff.header: #000080", + "hc_black": "meta.diff.header: #000080" + } + }, + { + "c": "index e4f37c4..557db03 100644", + "t": "source.diff meta.diff.index.git", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "---", + "t": "source.diff meta.diff.header.from-file punctuation.definition.from-file.diff", + "r": { + "dark_plus": "meta.diff.header: #569CD6", + "light_plus": "meta.diff.header: #000080", + "dark_vs": "meta.diff.header: #569CD6", + "light_vs": "meta.diff.header: #000080", + "hc_black": "meta.diff.header: #000080" + } + }, + { + "c": " a/helloworld.txt", + "t": "source.diff meta.diff.header.from-file", + "r": { + "dark_plus": "meta.diff.header: #569CD6", + "light_plus": "meta.diff.header: #000080", + "dark_vs": "meta.diff.header: #569CD6", + "light_vs": "meta.diff.header: #000080", + "hc_black": "meta.diff.header: #000080" + } + }, + { + "c": "+++", + "t": "source.diff meta.diff.header.to-file punctuation.definition.to-file.diff", + "r": { + "dark_plus": "meta.diff.header: #569CD6", + "light_plus": "meta.diff.header: #000080", + "dark_vs": "meta.diff.header: #569CD6", + "light_vs": "meta.diff.header: #000080", + "hc_black": "meta.diff.header: #000080" + } + }, + { + "c": " b/helloworld.txt", + "t": "source.diff meta.diff.header.to-file", + "r": { + "dark_plus": "meta.diff.header: #569CD6", + "light_plus": "meta.diff.header: #000080", + "dark_vs": "meta.diff.header: #569CD6", + "light_vs": "meta.diff.header: #000080", + "hc_black": "meta.diff.header: #000080" + } + }, + { + "c": "@@", + "t": "source.diff meta.diff.range.unified punctuation.definition.range.diff", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " ", + "t": "source.diff meta.diff.range.unified", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "-1 +1", + "t": "source.diff meta.diff.range.unified meta.toc-list.line-number.diff", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " ", + "t": "source.diff meta.diff.range.unified", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "@@", + "t": "source.diff meta.diff.range.unified punctuation.definition.range.diff", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "-", + "t": "source.diff markup.deleted.diff punctuation.definition.deleted.diff", + "r": { + "dark_plus": "markup.deleted: #CE9178", + "light_plus": "markup.deleted: #A31515", + "dark_vs": "markup.deleted: #CE9178", + "light_vs": "markup.deleted: #A31515", + "hc_black": "markup.deleted: #CE9178" + } + }, + { + "c": "Hello world", + "t": "source.diff markup.deleted.diff", + "r": { + "dark_plus": "markup.deleted: #CE9178", + "light_plus": "markup.deleted: #A31515", + "dark_vs": "markup.deleted: #CE9178", + "light_vs": "markup.deleted: #A31515", + "hc_black": "markup.deleted: #CE9178" + } + }, + { + "c": "+", + "t": "source.diff markup.inserted.diff punctuation.definition.inserted.diff", + "r": { + "dark_plus": "markup.inserted: #B5CEA8", + "light_plus": "markup.inserted: #09885A", + "dark_vs": "markup.inserted: #B5CEA8", + "light_vs": "markup.inserted: #09885A", + "hc_black": "markup.inserted: #B5CEA8" + } + }, + { + "c": "Hello World", + "t": "source.diff markup.inserted.diff", + "r": { + "dark_plus": "markup.inserted: #B5CEA8", + "light_plus": "markup.inserted: #09885A", + "dark_vs": "markup.inserted: #B5CEA8", + "light_vs": "markup.inserted: #09885A", + "hc_black": "markup.inserted: #B5CEA8" + } + } +] \ No newline at end of file