feat(indent): add basic java indentation queries (#7844)
commit1d189820a150eb38c55d419ad6dd350321d4c8ee
authorwoojiq <122799969+woojiq@users.noreply.github.com>
dateMon 7 Aug 2023, 16:48 (3 years ago)
parent80d2599
book/src/generated/lang-support.md+1−1
@@ -69,7 +69,7 @@
6969| idris | | | | `idris2-lsp` |
7070| iex | ✓ | | | |
7171| ini | ✓ | | | |
72−| java | ✓ | ✓ | | `jdtls` |
72+| java | ✓ | ✓ | ✓ | `jdtls` |
7373| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
7474| jsdoc | ✓ | | | |
7575| json | ✓ | | ✓ | `vscode-json-language-server` |
languages.toml+1−1
@@ -833,7 +833,7 @@ injection-regex = "java"
833833file-types = ["java"]
834834roots = ["pom.xml", "build.gradle", "build.gradle.kts"]
835835language-servers = [ "jdtls" ]
836−indent = { tab-width = 4, unit = " " }
836+indent = { tab-width = 2, unit = " " }
837837
838838[[grammar]]
839839name = "java"
runtime/queries/java/indents.scmnew file+35
@@ -0,0 +1,35 @@
1+[
2+ (class_body)
3+ (enum_body)
4+ (interface_body)
5+ (constructor_body)
6+ (annotation_type_body)
7+ (module_body)
8+ (block)
9+ (switch_block)
10+ (array_initializer)
11+ (argument_list)
12+ (formal_parameters)
13+ (annotation_argument_list)
14+ (element_value_array_initializer)
15+] @indent
16+
17+[
18+ "}"
19+ ")"
20+ "]"
21+] @outdent
22+
23+; Single statement after if/while/for without brackets
24+(if_statement
25+ consequence: (_) @indent
26+ (#not-kind-eq? @indent "block")
27+ (#set! "scope" "all"))
28+(while_statement
29+ body: (_) @indent
30+ (#not-kind-eq? @indent "block")
31+ (#set! "scope" "all"))
32+(for_statement
33+ (_) @indent
34+ (#not-kind-eq? @indent "block")
35+ (#set! "scope" "all"))