indents(go): improve @branch rules

- Don't branch at `case`
- Let `import_spec_list`/`var_declaration` behave like
  `const_declaration`

Fixes #2166
This commit is contained in:
Stephan Seitz 2022-08-05 21:04:21 +02:00
parent 3832fde3ee
commit 27424a2040
3 changed files with 35 additions and 1 deletions

View file

@ -14,11 +14,12 @@
] @indent
[
"case"
"}"
] @branch
(const_declaration ")" @branch)
(import_spec_list ")" @branch)
(var_declaration ")" @branch)
[
"}"

View file

@ -0,0 +1,19 @@
package main
var (
thing = 1
thingTwo = 2
) // <-- This paren should be at 0 instead of indented
var (
thing = 1
thingTwo = 2
)
func main() {
// It should be
var (
thing = 1
thingTwo = 2
)
}

14
tests/indent/go/switch.go Normal file
View file

@ -0,0 +1,14 @@
// issue #2166
package main
import (
"fmt"
)
func test(ch byte) {
fmt.Println("hey!")
switch ch {
case 'l':
return
}
}