Incorrect indentation after opening new lines with braces in Golang #11565
-
DescriptionWhen opening a new line directly after a Case 1 func main() {
if true {
fmt.Println("yes")
} else {|} // press enter here
}
Note: Both the cursor ( Case 2 func main() {
if true {
fmt.Println("yes")
}| //press enter here
} func main() {
if true {
fmt.Println("yes")
}
|
} Note: The cursor ( Related issues or PRsI've conducted a search on Google and found only one relevant pull request: #5713. ConfigureMy
My
My theme = "mymolokai"
[editor]
line-number = "relative"
mouse = false
insert-final-newline = true
jump-label-alphabet = "asdfhjklqweuiopcm"
[editor.lsp]
display-messages = true
[editor.gutters]
layout = ["line-numbers", "spacer", "diff" ]
[editor.statusline]
left = [ "mode", "separator" ]
center = [ "version-control", "file-name", "file-modification-indicator" ]
right = ["diagnostics", "position", "total-line-numbers"]
separator = "|"
mode.normal = "NOR"
mode.insert = "INSERT"
mode.select = "SELECT"
[editor.cursor-shape]
insert = "block"
normal = "block"
select = "block"
[editor.file-picker]
hidden = false
[keys.normal]
f = "goto_word"
H = "jump_backward"
L = "jump_forward"
"{" = "goto_prev_paragraph"
"}" = "goto_next_paragraph"
"X" = "select_line_above"
"x" = "select_line_below"
"minus" = "remove_primary_selection"
[keys.insert]
up = "no_op"
down = "no_op"
left = "no_op"
right = "no_op"
pageup = "no_op"
pagedown = "no_op"
home = "no_op"
end = "no_op" My languages.toml does not contain any specific configuration related to Golang. My [
(import_declaration)
(const_declaration)
(type_declaration)
(type_spec)
(func_literal)
(literal_value)
(literal_element)
(keyed_element)
(expression_case)
(default_case)
(type_case)
(communication_case)
(argument_list)
(field_declaration_list)
(block)
(var_declaration)
] @indent
[
"]"
")"
] @outdent
; Switches and selects aren't indented, only their case bodies are.
; Outdent all closing braces except those closing switches or selects.
(
(_ "}" @outdent) @outer
(#not-kind-eq? @outer "select_statement")
(#not-kind-eq? @outer "type_switch_statement")
(#not-kind-eq? @outer "expression_switch_statement")
)
; Starting a line after a new case should indent.
[
(communication_case)
(expression_case)
(default_case)
(type_case)
] @extend |
Beta Was this translation helpful? Give feedback.
Answered by
HairlessVillager
Aug 24, 2024
Replies: 1 comment
-
Solved by |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
HairlessVillager
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved by
:set indent-heuristic tree-sitter