Skip to content

Commit 26f2aea

Browse files
committed
Added basic syntax highlighting for the other most common programming languages
1 parent 633e75a commit 26f2aea

14 files changed

+1622
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
2+
3+
class BashSyntaxHighlighter : SyntaxHighlighter() {
4+
override fun loadKeywords(): List<String> = listOf(
5+
"case",
6+
"coproc",
7+
"do",
8+
"done",
9+
"elif",
10+
"else",
11+
"esac",
12+
"fi",
13+
"for",
14+
"function",
15+
"if",
16+
"in",
17+
"select",
18+
"then",
19+
"until",
20+
"while",
21+
"time",
22+
"[[",
23+
"]]"
24+
)
25+
26+
override fun isAnnotation(word: String): Boolean = false
27+
override fun isComment(line: String): Boolean = line.startsWith("#")
28+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
2+
3+
class CSharpSyntaxHighlighter : SyntaxHighlighter() {
4+
override fun loadKeywords(): List<String> = listOf(
5+
"abstract",
6+
"as",
7+
"base",
8+
"bool",
9+
"break",
10+
"byte",
11+
"case",
12+
"catch",
13+
"char",
14+
"checked",
15+
"class",
16+
"const",
17+
"continue",
18+
"decimal",
19+
"default",
20+
"delegate",
21+
"do",
22+
"double",
23+
"else",
24+
"enum",
25+
"event",
26+
"explicit",
27+
"extern",
28+
"false",
29+
"finally",
30+
"fixed",
31+
"float",
32+
"for",
33+
"foreach",
34+
"goto",
35+
"if",
36+
"implicit",
37+
"in",
38+
"int",
39+
"interface",
40+
"internal",
41+
"is",
42+
"lock",
43+
"long",
44+
"namespace",
45+
"new",
46+
"null",
47+
"object",
48+
"operator",
49+
"out",
50+
"override",
51+
"params",
52+
"private",
53+
"protected",
54+
"public",
55+
"readonly",
56+
"ref",
57+
"return",
58+
"sbyte",
59+
"sealed",
60+
"short",
61+
"sizeof",
62+
"stackalloc",
63+
"static",
64+
"string",
65+
"struct",
66+
"switch",
67+
"this",
68+
"throw",
69+
"true",
70+
"try",
71+
"typeof",
72+
"uint",
73+
"ulong",
74+
"unchecked",
75+
"unsafe",
76+
"ushort",
77+
"using",
78+
"virtual",
79+
"void",
80+
"volatile",
81+
"while",
82+
83+
)
84+
85+
override fun isAnnotation(word: String): Boolean = word.startsWith("[") && word.endsWith("]")
86+
override fun isComment(line: String): Boolean = line.startsWith("//")
87+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
2+
3+
class CppSyntaxHighlighter : SyntaxHighlighter() {
4+
override fun loadKeywords(): List<String> = listOf(
5+
"asm",
6+
"double",
7+
"new",
8+
"switch",
9+
"auto",
10+
"else",
11+
"operator",
12+
"template",
13+
"break",
14+
"enum",
15+
"private",
16+
"this",
17+
"case",
18+
"extern",
19+
"protected",
20+
"throw",
21+
"catch",
22+
"float",
23+
"public",
24+
"try",
25+
"char",
26+
"for",
27+
"register",
28+
"typedef",
29+
"class",
30+
"friend",
31+
"return",
32+
"union",
33+
"const",
34+
"#include",
35+
"#define",
36+
"#ifndef",
37+
"#endif",
38+
"goto",
39+
"short",
40+
"unsigned",
41+
"continue",
42+
"if",
43+
"signed",
44+
"virtual",
45+
"default",
46+
"inline",
47+
"sizeof",
48+
"void",
49+
"delete",
50+
"int",
51+
"static",
52+
"volatile",
53+
"do",
54+
"long",
55+
"struct",
56+
"while",
57+
)
58+
59+
override fun isAnnotation(word: String): Boolean = false
60+
override fun isComment(line: String): Boolean = line.startsWith("//")
61+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
2+
3+
class DartSyntaxHighlighter : SyntaxHighlighter() {
4+
override fun loadKeywords(): List<String> = listOf(
5+
"abstract",
6+
"as",
7+
"assert",
8+
"async",
9+
"await",
10+
"base",
11+
"break",
12+
"case",
13+
"catch",
14+
"class",
15+
"const",
16+
"continue",
17+
"covariant",
18+
"default",
19+
"deferred",
20+
"do",
21+
"dynamic",
22+
"else",
23+
"enum",
24+
"export",
25+
"extends",
26+
"extension",
27+
"external",
28+
"factory",
29+
"false",
30+
"final",
31+
"finally",
32+
"for",
33+
"Function",
34+
"get",
35+
"hide",
36+
"if",
37+
"implements",
38+
"import",
39+
"in",
40+
"interface",
41+
"is",
42+
"late",
43+
"library",
44+
"mixin",
45+
"new",
46+
"null",
47+
"of",
48+
"on",
49+
"operator",
50+
"part",
51+
"required",
52+
"rethrow",
53+
"return",
54+
"sealed ",
55+
"set",
56+
"show ",
57+
"static",
58+
"super",
59+
"switch",
60+
"sync ",
61+
"this",
62+
"throw",
63+
"true",
64+
"try",
65+
"type",
66+
"typedef",
67+
"var",
68+
"void",
69+
"when ",
70+
"with",
71+
"while",
72+
)
73+
74+
override fun isAnnotation(word: String): Boolean = word.startsWith("@")
75+
override fun isComment(line: String): Boolean = line.startsWith("//")
76+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
2+
3+
class GoSyntaxHighlighter : SyntaxHighlighter() {
4+
override fun loadKeywords(): List<String> = listOf(
5+
"break",
6+
"default",
7+
"func",
8+
"interface",
9+
"select",
10+
"case",
11+
"defer",
12+
"go",
13+
"map",
14+
"struct",
15+
"chan",
16+
"else",
17+
"goto",
18+
"package",
19+
"switch",
20+
"const",
21+
"fallthrough",
22+
"if",
23+
"range",
24+
"type",
25+
"continue",
26+
"for",
27+
"import",
28+
"return",
29+
"var",
30+
)
31+
32+
override fun isAnnotation(word: String): Boolean = false
33+
override fun isComment(line: String): Boolean = line.startsWith("//")
34+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
2+
3+
class JavaSyntaxHighlighter : SyntaxHighlighter() {
4+
override fun loadKeywords(): List<String> = listOf(
5+
"abstract",
6+
"continue",
7+
"for",
8+
"new",
9+
"switch",
10+
"assert",
11+
"default",
12+
"goto*",
13+
"package",
14+
"synchronized",
15+
"boolean",
16+
"do",
17+
"if",
18+
"private",
19+
"this",
20+
"break",
21+
"double",
22+
"implements",
23+
"protected",
24+
"throw",
25+
"byte",
26+
"else",
27+
"import",
28+
"public",
29+
"throws",
30+
"case",
31+
"enum****",
32+
"instanceof",
33+
"return",
34+
"transient",
35+
"catch",
36+
"extends",
37+
"int",
38+
"short",
39+
"try",
40+
"char",
41+
"final",
42+
"interface",
43+
"static",
44+
"void",
45+
"class",
46+
"finally",
47+
"long",
48+
"strictfp**",
49+
"volatile",
50+
"const*",
51+
"float",
52+
"native",
53+
"super",
54+
"while",
55+
)
56+
57+
override fun isAnnotation(word: String): Boolean = word.startsWith("@")
58+
override fun isComment(line: String): Boolean = line.startsWith("//")
59+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter
2+
3+
class LuaSyntaxHighlighter : SyntaxHighlighter() {
4+
override fun loadKeywords(): List<String> = listOf(
5+
"and",
6+
"break",
7+
"do",
8+
"else",
9+
"elseif",
10+
"end",
11+
"false",
12+
"for",
13+
"function",
14+
"if",
15+
"in",
16+
"local",
17+
"nil",
18+
"not",
19+
"or",
20+
"repeat",
21+
"return",
22+
"then",
23+
"true",
24+
"until",
25+
"while"
26+
)
27+
28+
override fun isAnnotation(word: String): Boolean = false
29+
override fun isComment(line: String): Boolean = line.startsWith("--")
30+
}

0 commit comments

Comments
 (0)