Skip to content

Commit 413a0dd

Browse files
committed
feat: add support for syntax highlighting for diff/patch files
1 parent 8e7ee7c commit 413a0dd

8 files changed

Lines changed: 222 additions & 5 deletions

File tree

org.eclipse.tm4e.language_pack/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ for the [Eclipse IDE](https://eclipseide.org).
3434
| CSS | file-extensions="css" | [1.87.0@microsoft/vscode](https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/css) [[upstream]](https://github.com/microsoft/vscode-css/commit/c216f777497265700ff336f739328e5197e012cd)
3535
| CUDA C++ | file-extensions="cu, cuh" | [1.87.0@microsoft/vscode](https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/cpp) [[upstream]](https://github.com/NVIDIA/cuda-cpp-grammar/commit/81e88eaec5170aa8585736c63627c73e3589998c)
3636
| Dart | file-extensions="dart" | [1.87.0@microsoft/vscode](https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/dart) [[upstream]](https://github.com/dart-lang/dart-syntax-highlight/commit/0a6648177bdbb91a4e1a38c16e57ede0ccba4f18)
37+
| Diff | file-extensions="diff, patch, rej" | [1.87.0@microsoft/vscode](https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/diff) [[upstream]](https://github.com/textmate/diff.tmbundle/commit/0593bb775eab1824af97ef2172fd38822abd97d7)
3738
| Docker | file-extensions="containerfile, dockerfile"<br />file-names="Containerfile, Dockerfile"<br />file-patterns="Containerfile.\*, Dockerfile.\*" | [1.87.0@microsoft/vscode](https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/docker) [[upstream]](https://github.com/moby/moby/commit/abd39744c6f3ed854500e423f5fabf952165161f)
3839
| F# | file-extensions="fs, fsi, fsscript, fsx" | [1.87.0@microsoft/vscode](https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/fsharp) [[upstream]](https://github.com/ionide/ionide-fsgrammar/commit/7d029a46f17637228b2ee85dd02e511c3e8039b3)
3940
| Git Commit Message <img src="syntaxes/git-base/icon.png" width=16/> | file-names="COMMIT_EDITMSG, MERGE_MSG" | [1.87.0@microsoft/vscode](https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/git-base) [[upstream]](https://github.com/walles/git-commit-message-plus/commit/35a079dea5a91b087021b40c01a6bb4eb0337a87)

org.eclipse.tm4e.language_pack/about.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ <h2>About This Content</h2>
9797
<td>file-extensions="dart"</td>
9898
<td><a href="https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/dart">1.87.0@microsoft/vscode</a> <a href="https://github.com/dart-lang/dart-syntax-highlight/commit/0a6648177bdbb91a4e1a38c16e57ede0ccba4f18">[upstream]</a>
9999
</tr>
100+
<tr>
101+
<td>Diff</td>
102+
<td>file-extensions="diff, patch, rej"</td>
103+
<td><a href="https://github.com/microsoft/vscode/tree/019f4d1419fbc8219a181fab7892ebccf7ee29a2/extensions/diff">1.87.0@microsoft/vscode</a> <a href="https://github.com/textmate/diff.tmbundle/commit/0593bb775eab1824af97ef2172fd38822abd97d7">[upstream]</a>
104+
</tr>
100105
<tr>
101106
<td>Docker</td>
102107
<td>file-extensions="containerfile, dockerfile"<br />file-names="Containerfile, Dockerfile"<br />file-patterns="Containerfile.*, Dockerfile.*"</td>

org.eclipse.tm4e.language_pack/plugin.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,26 @@
280280
<snippet name="Dart Example" path="syntaxes/dart/dart.example.dart" scopeName="source.dart" />
281281
</extension>
282282

283+
<!-- ======================================== -->
284+
<!-- diff/diff: Diff -->
285+
<!-- ======================================== -->
286+
<extension point="org.eclipse.core.contenttype.contentTypes">
287+
<content-type id="org.eclipse.tm4e.language_pack.diff" name="Diff" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
288+
file-extensions="diff,patch,rej" />
289+
</extension>
290+
<extension point="org.eclipse.tm4e.registry.grammars">
291+
<grammar scopeName="source.diff" path="syntaxes/diff/diff.tmLanguage.json" />
292+
<scopeNameContentTypeBinding scopeName="source.diff" contentTypeId="org.eclipse.tm4e.language_pack.diff" />
293+
</extension>
294+
295+
<extension point="org.eclipse.tm4e.languageconfiguration.languageConfigurations">
296+
<languageConfiguration contentTypeId="org.eclipse.tm4e.language_pack.diff" path="syntaxes/diff/diff.language-configuration.json" />
297+
</extension>
298+
299+
<extension point="org.eclipse.tm4e.ui.snippets">
300+
<snippet name="Diff Example" path="syntaxes/diff/diff.example.diff" scopeName="source.diff" />
301+
</extension>
302+
283303
<!-- ======================================== -->
284304
<!-- docker/dockerfile: Docker -->
285305
<!-- ======================================== -->
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- script1.py 2024-05-16 10:00:00.000000000 +0000
2+
+++ script2.py 2024-05-16 10:00:00.000000000 +0000
3+
@@ -1,6 +1,9 @@
4+
# script1.py
5+
def greet(name):
6+
- print("Hello, " + name + "!")
7+
+ print("Hi, " + name + "!")
8+
9+
def calculate_sum(a, b):
10+
- return a + b
11+
+ result = a + b
12+
+ print("The sum of", a, "and", b, "is", result)
13+
+ return result * 2
14+
+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"comments": {
3+
"lineComment": "#",
4+
"blockComment": [ "#", " " ]
5+
},
6+
"brackets": [
7+
["{", "}"],
8+
["[", "]"],
9+
["(", ")"]
10+
]
11+
}
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
{
2+
"information_for_contributors": [
3+
"This file has been converted from https://github.com/textmate/diff.tmbundle/blob/master/Syntaxes/Diff.plist",
4+
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
5+
"Once accepted there, we are happy to receive an update request."
6+
],
7+
"version": "https://github.com/textmate/diff.tmbundle/commit/0593bb775eab1824af97ef2172fd38822abd97d7",
8+
"name": "Diff",
9+
"scopeName": "source.diff",
10+
"patterns": [
11+
{
12+
"captures": {
13+
"1": {
14+
"name": "punctuation.definition.separator.diff"
15+
}
16+
},
17+
"match": "^((\\*{15})|(={67})|(-{3}))$\\n?",
18+
"name": "meta.separator.diff"
19+
},
20+
{
21+
"match": "^\\d+(,\\d+)*(a|d|c)\\d+(,\\d+)*$\\n?",
22+
"name": "meta.diff.range.normal"
23+
},
24+
{
25+
"captures": {
26+
"1": {
27+
"name": "punctuation.definition.range.diff"
28+
},
29+
"2": {
30+
"name": "meta.toc-list.line-number.diff"
31+
},
32+
"3": {
33+
"name": "punctuation.definition.range.diff"
34+
}
35+
},
36+
"match": "^(@@)\\s*(.+?)\\s*(@@)($\\n?)?",
37+
"name": "meta.diff.range.unified"
38+
},
39+
{
40+
"captures": {
41+
"3": {
42+
"name": "punctuation.definition.range.diff"
43+
},
44+
"4": {
45+
"name": "punctuation.definition.range.diff"
46+
},
47+
"6": {
48+
"name": "punctuation.definition.range.diff"
49+
},
50+
"7": {
51+
"name": "punctuation.definition.range.diff"
52+
}
53+
},
54+
"match": "^(((\\-{3}) .+ (\\-{4}))|((\\*{3}) .+ (\\*{4})))$\\n?",
55+
"name": "meta.diff.range.context"
56+
},
57+
{
58+
"match": "^diff --git a/.*$\\n?",
59+
"name": "meta.diff.header.git"
60+
},
61+
{
62+
"match": "^diff (-|\\S+\\s+\\S+).*$\\n?",
63+
"name": "meta.diff.header.command"
64+
},
65+
{
66+
"captures": {
67+
"4": {
68+
"name": "punctuation.definition.from-file.diff"
69+
},
70+
"6": {
71+
"name": "punctuation.definition.from-file.diff"
72+
},
73+
"7": {
74+
"name": "punctuation.definition.from-file.diff"
75+
}
76+
},
77+
"match": "(^(((-{3}) .+)|((\\*{3}) .+))$\\n?|^(={4}) .+(?= - ))",
78+
"name": "meta.diff.header.from-file"
79+
},
80+
{
81+
"captures": {
82+
"2": {
83+
"name": "punctuation.definition.to-file.diff"
84+
},
85+
"3": {
86+
"name": "punctuation.definition.to-file.diff"
87+
},
88+
"4": {
89+
"name": "punctuation.definition.to-file.diff"
90+
}
91+
},
92+
"match": "(^(\\+{3}) .+$\\n?| (-) .* (={4})$\\n?)",
93+
"name": "meta.diff.header.to-file"
94+
},
95+
{
96+
"captures": {
97+
"3": {
98+
"name": "punctuation.definition.inserted.diff"
99+
},
100+
"6": {
101+
"name": "punctuation.definition.inserted.diff"
102+
}
103+
},
104+
"match": "^(((>)( .*)?)|((\\+).*))$\\n?",
105+
"name": "markup.inserted.diff"
106+
},
107+
{
108+
"captures": {
109+
"1": {
110+
"name": "punctuation.definition.changed.diff"
111+
}
112+
},
113+
"match": "^(!).*$\\n?",
114+
"name": "markup.changed.diff"
115+
},
116+
{
117+
"captures": {
118+
"3": {
119+
"name": "punctuation.definition.deleted.diff"
120+
},
121+
"6": {
122+
"name": "punctuation.definition.deleted.diff"
123+
}
124+
},
125+
"match": "^(((<)( .*)?)|((-).*))$\\n?",
126+
"name": "markup.deleted.diff"
127+
},
128+
{
129+
"begin": "^(#)",
130+
"captures": {
131+
"1": {
132+
"name": "punctuation.definition.comment.diff"
133+
}
134+
},
135+
"comment": "Git produces unified diffs with embedded comments\"",
136+
"end": "\\n",
137+
"name": "comment.line.number-sign.diff"
138+
},
139+
{
140+
"match": "^index [0-9a-f]{7,40}\\.\\.[0-9a-f]{7,40}.*$\\n?",
141+
"name": "meta.diff.index.git"
142+
},
143+
{
144+
"captures": {
145+
"1": {
146+
"name": "punctuation.separator.key-value.diff"
147+
},
148+
"2": {
149+
"name": "meta.toc-list.file-name.diff"
150+
}
151+
},
152+
"match": "^Index(:) (.+)$\\n?",
153+
"name": "meta.diff.index"
154+
},
155+
{
156+
"match": "^Only in .*: .*$\\n?",
157+
"name": "meta.diff.only-in"
158+
}
159+
]
160+
}

org.eclipse.tm4e.language_pack/updater/updater-config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ sources:
103103
bat:
104104
label: Batch File
105105

106-
diff:
107-
ignored: theme support required
108-
109106
git-base:
110107
languages:
111108
ignore:

org.eclipse.tm4e.language_pack/updater/updater-state.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,17 @@ extensions:
138138
github:
139139
repo: microsoft/vscode
140140
path: extensions/diff
141-
ref: 1.84.0
142-
commit: d037ac076cee195194f93ce6fe2bdfe2969cc82d
141+
ref: 1.87.0
142+
commit: 019f4d1419fbc8219a181fab7892ebccf7ee29a2
143+
languages:
144+
diff:
145+
label: Diff
146+
scope-name: source.diff
147+
upstream-url: https://github.com/textmate/diff.tmbundle/commit/0593bb775eab1824af97ef2172fd38822abd97d7
148+
file-extensions:
149+
- .diff
150+
- .patch
151+
- .rej
143152
docker:
144153
github:
145154
repo: microsoft/vscode

0 commit comments

Comments
 (0)