on master help sign in
add java highlighting (#448)
commitb239f0f45ffd0993cffc2a676651a0770b705fb5 authorKirawi <67773714+kirawi@users.noreply.github.com> dateTue 10 Aug 2021, 01:09 (5 years ago) parent86209c9
2 files changed+137
languages.toml+8 runtime/queries/java/highlights.scm+129
languages.toml+8
@@ -197,6 +197,14 @@ comment-token = "#"
197197language-server = { command = "julia", args = [ "--startup-file=no", "--history-file=no", "-e", "using LanguageServer;using Pkg;import StaticLint;import SymbolServer;env_path = dirname(Pkg.Types.Context().env.project_file);server = LanguageServer.LanguageServerInstance(stdin, stdout, env_path, \"\");server.runlinter = true;run(server);" ] }
198198indent = { tab-width = 2, unit = " " }
199199
200+[[language]]
201+name = "java"
202+scope = "source.java"
203+injection-regex = "java"
204+file-types = ["java"]
205+roots = []
206+indent = { tab-width = 4, unit = " " }
207+
200208# [[language]]
201209# name = "haskell"
202210# scope = "source.haskell"
runtime/queries/java/highlights.scmnew file+129
@@ -0,0 +1,129 @@
1+; Methods
2+
3+(method_declaration
4+ name: (identifier) @function.method)
5+(method_invocation
6+ name: (identifier) @function.method)
7+(super) @function.builtin
8+
9+; Annotations
10+
11+(annotation
12+ name: (identifier) @attribute)
13+(marker_annotation
14+ name: (identifier) @attribute)
15+
16+"@" @operator
17+
18+; Types
19+
20+(interface_declaration
21+ name: (identifier) @type)
22+(class_declaration
23+ name: (identifier) @type)
24+(enum_declaration
25+ name: (identifier) @type)
26+
27+((field_access
28+ object: (identifier) @type)
29+ (#match? @type "^[A-Z]"))
30+((scoped_identifier
31+ scope: (identifier) @type)
32+ (#match? @type "^[A-Z]"))
33+
34+(constructor_declaration
35+ name: (identifier) @type)
36+
37+(type_identifier) @type
38+
39+[
40+ (boolean_type)
41+ (integral_type)
42+ (floating_point_type)
43+ (floating_point_type)
44+ (void_type)
45+] @type.builtin
46+
47+; Variables
48+
49+((identifier) @constant
50+ (#match? @constant "^_*[A-Z][A-Z\d_]+"))
51+
52+(identifier) @variable
53+
54+(this) @variable.builtin
55+
56+; Literals
57+
58+[
59+ (hex_integer_literal)
60+ (decimal_integer_literal)
61+ (octal_integer_literal)
62+ (decimal_floating_point_literal)
63+ (hex_floating_point_literal)
64+] @number
65+
66+[
67+ (character_literal)
68+ (string_literal)
69+] @string
70+
71+[
72+ (true)
73+ (false)
74+ (null_literal)
75+] @constant.builtin
76+
77+(comment) @comment
78+
79+; Keywords
80+
81+[
82+ "abstract"
83+ "assert"
84+ "break"
85+ "case"
86+ "catch"
87+ "class"
88+ "continue"
89+ "default"
90+ "do"
91+ "else"
92+ "enum"
93+ "exports"
94+ "extends"
95+ "final"
96+ "finally"
97+ "for"
98+ "if"
99+ "implements"
100+ "import"
101+ "instanceof"
102+ "interface"
103+ "module"
104+ "native"
105+ "new"
106+ "open"
107+ "opens"
108+ "package"
109+ "private"
110+ "protected"
111+ "provides"
112+ "public"
113+ "requires"
114+ "return"
115+ "static"
116+ "strictfp"
117+ "switch"
118+ "synchronized"
119+ "throw"
120+ "throws"
121+ "to"
122+ "transient"
123+ "transitive"
124+ "try"
125+ "uses"
126+ "volatile"
127+ "while"
128+ "with"
129+] @keyword