diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax deleted file mode 100644 index 740684f717..0000000000 --- a/Diff/Conflict.sublime-syntax +++ /dev/null @@ -1,97 +0,0 @@ -%YAML 1.2 ---- -# https://www.sublimetext.com/docs/syntax.html -# https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 -name: Conflict -scope: source.conflict -version: 2 - -file_extensions: - - conflict - -contexts: - main: - - include: conflicts - - # Utility context for others to use - conflict-markers: - - match: ^({{any}})\s*({{identifier}})\s*{{eol}} - captures: - 1: punctuation.section.block.conflict - 2: entity.name.section.conflict - - conflicts: - - match: ^(?={{begin}}) - push: - - conflict - - conflict-marker-start - - conflict: - - meta_scope: meta.block.conflict - - match: '' - pop: 1 - - conflict-marker-start: - - match: '{{begin}}' - scope: punctuation.section.block.begin.conflict - - match: (?:({{identifier}})\s*)?{{eol}} - captures: - 1: entity.name.section.conflict - set: deleted-lines - - base-marker-start: - - match: '{{base}}' - scope: punctuation.section.block.conflict - - match: (?:({{identifier}})\s*)?{{eol}} - captures: - 1: entity.name.section.conflict - set: base-lines - - split-marker-start: - - match: '{{split}}' - scope: punctuation.section.block.conflict - - match: (?:({{identifier}})\s*)?{{eol}} - captures: - 1: entity.name.section.conflict - set: new-lines - - deleted-lines: - - meta_content_scope: markup.deleted.conflict - - match: ^(?={{base}}) - set: base-marker-start - - match: ^(?={{split}}) - set: split-marker-start - - include: invalid-conflict-marker - - base-lines: - - meta_content_scope: comment.block.conflict - - match: ^(?={{split}}) - set: split-marker-start - - include: invalid-conflict-marker - - new-lines: - - meta_content_scope: markup.inserted.conflict - - match: ^({{end}})\s*(?:({{identifier}})\s*)?{{eol}} - captures: - 1: punctuation.section.block.end.conflict - 2: entity.name.section.conflict - pop: 1 - # Nested conflicts in ReReRe - - include: conflicts - - include: invalid-conflict-marker - - invalid-conflict-marker: - - match: ^(?:{{any}}) - scope: invalid.illegal.conflict - - -variables: - eol: (?:$\n?) - - begin: <{5,} - end: '>{5,}' - split: ={5,} - base: \|{5,} - any: (?:{{begin}}|{{end}}|{{split}}|{{base}}) - - identifier: (?:\S.*?) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 1eb3b8371a..4dca8144e6 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -36,11 +36,10 @@ contexts: diffs: - include: diff-line-ranges - include: diff-header + - include: conflicts - include: diff-deltas - include: diff3-edit - include: diff3-normal - # Diff3 Edit conflicts with non-diff3 Normal mode, so it's off by default. - # With branching, it could probably be enabled, too. ###[ HEADERS ]################################################################# @@ -240,3 +239,93 @@ contexts: - match: ^\.$ scope: punctuation.terminator.hunk.diff pop: 1 + +###[ CONFLICTS ]############################################################### + + # Utility context for other files to use + conflict-markers: + - match: ^({{conflict_any}})\s*({{conflict_identifier}})\s*{{eol}} + captures: + 1: punctuation.section.block.diff + 2: entity.name.section.diff + + conflicts: + - match: ^(?={{conflict_begin}}) + push: + - conflict + - conflict-marker-start + + conflict: + - meta_scope: meta.block.conflict.diff + - match: '' + pop: 1 + + conflict-marker-start: + - match: '{{conflict_begin}}' + scope: punctuation.section.block.begin.diff + - match: (?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: entity.name.section.diff + set: conflict-deleted-lines + + conflict-base-marker-start: + - match: '{{conflict_base}}' + scope: punctuation.section.block.diff + - match: (?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: entity.name.section.diff + set: conflict-base-lines + + conflict-split-marker-start: + - match: '{{conflict_split}}' + scope: punctuation.section.block.diff + - match: (?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: entity.name.section.diff + set: conflict-new-lines + + conflict-deleted-lines: + - meta_content_scope: markup.deleted.diff + - match: ^(?={{conflict_base}}) + set: conflict-base-marker-start + - match: ^(?={{conflict_split}}) + set: conflict-split-marker-start + - include: invalid-conflict-marker + + conflict-base-lines: + - meta_content_scope: comment.block.diff + - match: ^(?={{conflict_split}}) + set: conflict-split-marker-start + - include: invalid-conflict-marker + + conflict-new-lines: + - meta_content_scope: markup.inserted.diff + - match: ^({{conflict_end}})\s*(?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: punctuation.section.block.end.diff + 2: entity.name.section.diff + pop: 1 + # Nested conflicts in Git ReReRe + - include: conflicts + - include: invalid-conflict-marker + + invalid-conflict-marker: + - match: ^(?:{{conflict_any}}) + scope: invalid.illegal.conflict.diff + +############################################################################### + +variables: + conflict_begin: <{5,} + conflict_end: '>{5,}' + conflict_split: ={5,} + conflict_base: \|{5,} + conflict_any: |- + (?x: + {{conflict_begin}} + | {{conflict_end}} + | {{conflict_split}} + | {{conflict_base}} + ) + + conflict_identifier: (?:\S.*?) diff --git a/Diff/tests/syntax_test_conflict.conflict b/Diff/tests/syntax_test_conflict.conflict deleted file mode 100644 index cb1d2adbe6..0000000000 --- a/Diff/tests/syntax_test_conflict.conflict +++ /dev/null @@ -1,157 +0,0 @@ -\ SYNTAX TEST "Packages/Diff/Conflict.sublime-syntax" - -https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 -<<<<<<< A -\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.section.block.begin.conflict -\ ^ - entity - punctuation -\ ^ entity.name.section.conflict -\ ^ - entity -lines from A -\^^^^^^^^^^^^ meta.block.conflict markup.deleted.conflict - meta.block meta.block -======= -\^^^^^^ meta.block.conflict punctuation.section.block.conflict - meta.block meta.block - markup -lines from B -\^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict ->>>>>>> B -\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.section.block.end.conflict -\ ^ - entity -\ ^ entity.name.section.conflict -\ ^ - entity -context context -\^^^^^^^^^^^^^^^ - meta.block - -<<<<<<< A -lines from A -||||||| B -\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.section.block.conflict -\ ^ - entity - punctuation -\ ^ entity.name.section.conflict -\ ^ - entity -lines from B -\^^^^^^^^^^^^ meta.block.conflict comment.block.conflict - meta.block meta.block - markup -======= -\^^^^^^ meta.block.conflict punctuation.section.block.conflict - meta.block meta.block - markup -> -\ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid -< -\ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid -||||| -\^^^^ meta.block.conflict markup.inserted.conflict invalid.illegal.conflict -lines from C -\^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict ->>>>>>> C -context context -\ <- - meta.block - -<<<<<<< tzu -======= -The Way that can be told of is not the eternal Way; -The name that can be named is not the eternal name. ->>>>>>> tao - -<<<<<<< lao -||||||| tzu -They both may be called deep and profound. -Deeper and more profound, -The door of all subtleties! -======= - - -- The Way of Lao-Tzu, tr. Wing-tsit Chan ->>>>>>> tao - -<<<<<<< lao -======= - - -- The Way of Lao-Tzu, tr. Wing-tsit Chan ->>>>>>> tao - - -https://www.gnu.org/software/diffutils/manual/diffutils.html#Generating-the-Merged-Output-Directly -<<<<<<< tzu -======= -The Way that can be told of is not the eternal Way; -The name that can be named is not the eternal name. ->>>>>>> tao -The Nameless is the origin of Heaven and Earth; -The Named is the mother of all things. -Therefore let there always be non-being, - so we may see their subtlety, -And let there always be being, - so we may see their result. -The two are the same, -But after they are produced, - they have different names. -<<<<<<< lao -||||||| tzu -They both may be called deep and profound. -Deeper and more profound, -The door of all subtleties! -======= - - -- The Way of Lao-Tzu, tr. Wing-tsit Chan ->>>>>>> tao - -If you have questions, please -<<<<<<< HEAD -open an issue -======= -ask your question in IRC. ->>>>>>> branch-a - - -\ https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging -#! /usr/bin/env ruby - -def hello -<<<<<<< ours - puts 'hola world' -||||||| base - puts 'hello world' -======= - puts 'hello mundo' ->>>>>>> theirs -end - -hello() - - -\ https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts -<<<<<<< HEAD:index.html -
-======= - ->>>>>>> iss53:index.html - - -\ https://git-scm.com/docs/rerere.html#_nested_conflicts -<<<<<<< HEAD -\^^^^^^^^^^^ meta.block.conflict -\^^^^^^ punctuation.section.block.begin.conflict -\ ^^^^ entity.name.section.conflict -111 -\^^ meta.block.conflict markup.deleted.conflict -======= -\^^^^^^ meta.block.conflict punctuation.section.block.conflict -<<<<<<< HEAD -\^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict -\^^^^^^ punctuation.section.block.begin.conflict -\ ^^^^ entity.name.section.conflict -333 -\^^ meta.block.conflict markup.inserted.conflict meta.block.conflict markup.deleted.conflict -======= -\^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict punctuation.section.block.conflict -222 -\^^ meta.block.conflict markup.inserted.conflict meta.block.conflict markup.inserted.conflict ->>>>>>> branch-2 -\^^^^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict -\^^^^^^ punctuation.section.block.end.conflict -\ ^^^^^^^^ entity.name.section.conflict ->>>>>>> branch-3~ -\^^^^^^^^^^^^^^^^ meta.block.conflict -\^^^^^^ punctuation.section.block.end.conflict -\ ^^^^^^^^^ entity.name.section.conflict diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 246f10901f..87a99aeabc 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -403,3 +403,162 @@ Index: added-file +++ added-file (working copy) @@ -0,0 +1 @@ +This is an added file. + + +https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 +<<<<<<< A +\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.begin.diff +\ ^ - entity - punctuation +\ ^ entity.name.section.diff +\ ^ - entity +lines from A +\^^^^^^^^^^^^ meta.block.conflict.diff markup.deleted.diff - meta.block meta.block +======= +\^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.diff +lines from B +\^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff +>>>>>>> B +\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.end.diff +\ ^ - entity +\ ^ entity.name.section.diff +\ ^ - entity +context context +\^^^^^^^^^^^^^^^ - meta.block + +<<<<<<< A +lines from A +||||||| B +\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.diff +\ ^ - entity - punctuation +\ ^ entity.name.section.diff +\ ^ - entity +lines from B +\^^^^^^^^^^^^ meta.block.conflict.diff comment.block.diff - meta.block meta.block - markup +======= +\^^^^^^ meta.block.conflict.diff punctuation.section.block.diff - meta.block meta.block - markup +> +\ <- meta.block.conflict.diff markup.inserted.diff - punctuation - invalid +< +\ <- meta.block.conflict.diff markup.inserted.diff - punctuation - invalid +||||| +\^^^^ meta.block.conflict.diff markup.inserted.diff invalid.illegal.conflict.diff +lines from C +\^^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff +>>>>>>> C +context context +\ <- - meta.block + +<<<<<<< tzu +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> tao + +<<<<<<< lao +||||||| tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + +<<<<<<< lao +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + + +https://www.gnu.org/software/diffutils/manual/diffutils.html#Generating-the-Merged-Output-Directly +<<<<<<< tzu +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> tao +The Nameless is the origin of Heaven and Earth; +The Named is the mother of all things. +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their result. +The two are the same, +But after they are produced, + they have different names. +<<<<<<< lao +||||||| tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + +If you have questions, please +<<<<<<< HEAD +open an issue +======= +ask your question in IRC. +>>>>>>> branch-a + + +\ https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging +#! /usr/bin/env ruby + +def hello +<<<<<<< ours + puts 'hola world' +||||||| base + puts 'hello world' +======= + puts 'hello mundo' +>>>>>>> theirs +end + +hello() + + +\ https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts +<<<<<<< HEAD:index.html + +======= + +>>>>>>> iss53:index.html + + +\ https://git-scm.com/docs/rerere.html#_nested_conflicts +<<<<<<< HEAD +\^^^^^^^^^^^^ meta.block.conflict.diff +\^^^^^^ punctuation.section.block.begin.diff +\ ^^^^ entity.name.section.diff +111 +\^^ meta.block.conflict.diff markup.deleted.diff +======= +\^^^^^^^ meta.block.conflict.diff +\^^^^^^ punctuation.section.block.diff +<<<<<<< HEAD +\^^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.diff +\^^^^^^ punctuation.section.block.begin.diff +\ ^^^^ entity.name.section.diff +333 +\^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.diff markup.deleted.diff +======= +\^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict punctuation.section.block.diff +222 +\^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict markup.inserted.diff +>>>>>>> branch-2 +\^^^^^^^^^^^^^^^ meta.block.conflict markup.inserted.diff meta.block.conflict.diff +\^^^^^^ punctuation.section.block.end.diff +\ ^^^^^^^^ entity.name.section.diff +>>>>>>> branch-3~ +\^^^^^^^^^^^^^^^^ meta.block.conflict.diff +\^^^^^^ punctuation.section.block.end.diff +\ ^^^^^^^^^ entity.name.section.diff