mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
fix(indent): rust - support newline after closing brace
This commit is contained in:
parent
7a6d93ca5b
commit
c2e3938510
2 changed files with 23 additions and 0 deletions
|
|
@ -27,6 +27,20 @@
|
|||
(trait_item body: (_) @indent)
|
||||
(string_literal (escape_sequence)) @indent
|
||||
|
||||
(block "}" @indent_end)
|
||||
(enum_item
|
||||
body: (enum_variant_list "}" @indent_end))
|
||||
(impl_item
|
||||
body: (declaration_list "}" @indent_end))
|
||||
(match_expression
|
||||
body: (match_block "}" @indent_end))
|
||||
(mod_item
|
||||
body: (declaration_list "}" @indent_end))
|
||||
(struct_item
|
||||
body: (field_declaration_list "}" @indent_end))
|
||||
(trait_item
|
||||
body: (declaration_list "}" @indent_end))
|
||||
|
||||
(impl_item (where_clause) @dedent)
|
||||
|
||||
[
|
||||
|
|
|
|||
|
|
@ -20,13 +20,18 @@ describe("indent Rust:", function()
|
|||
run:new_line("cond.rs", { on_line = 2, text = "x += 1;", indent = 8 })
|
||||
run:new_line("cond.rs", { on_line = 4, text = "x += 1;", indent = 8 })
|
||||
run:new_line("cond.rs", { on_line = 6, text = "x += 1;", indent = 8 })
|
||||
run:new_line("cond.rs", { on_line = 8, text = "x += 1;", indent = 4 })
|
||||
run:new_line("enum.rs", { on_line = 2, text = "Q,", indent = 4 })
|
||||
run:new_line("enum.rs", { on_line = 4, text = "i32,", indent = 8 })
|
||||
run:new_line("enum.rs", { on_line = 8, text = "z: u32,", indent = 8 })
|
||||
run:new_line("enum.rs", { on_line = 11, text = "let _x = 1;", indent = 0 })
|
||||
run:new_line("func.rs", { on_line = 1, text = "let _x = 1;", indent = 4 })
|
||||
run:new_line("func.rs", { on_line = 3, text = "let _x = 1;", indent = 0 })
|
||||
run:new_line("func.rs", { on_line = 6, text = "z: i32,", indent = 4 })
|
||||
run:new_line("impl.rs", { on_line = 3, text = "const FOO: u32 = 1;", indent = 4 })
|
||||
run:new_line("impl.rs", { on_line = 4, text = "let _x = 1;", indent = 8 })
|
||||
run:new_line("impl.rs", { on_line = 6, text = "let _x = 1;", indent = 4 })
|
||||
run:new_line("impl.rs", { on_line = 7, text = "let _x = 1;", indent = 0 })
|
||||
run:new_line("loop.rs", { on_line = 10, text = "x += 1;", indent = 8 })
|
||||
run:new_line("loop.rs", { on_line = 2, text = "x += 1;", indent = 8 })
|
||||
run:new_line("loop.rs", { on_line = 6, text = "x += 1;", indent = 8 })
|
||||
|
|
@ -35,15 +40,19 @@ describe("indent Rust:", function()
|
|||
run:new_line("macro.rs", { on_line = 2, text = "struct $c;", indent = 8 })
|
||||
run:new_line("match.rs", { on_line = 2, text = "-1 => -1,", indent = 8 })
|
||||
run:new_line("match.rs", { on_line = 7, text = "let y = 1;", indent = 12 })
|
||||
run:new_line("match.rs", { on_line = 10, text = "let y = 1;", indent = 4 })
|
||||
run:new_line("mod.rs", { on_line = 1, text = "const Z: i32 = 1;", indent = 4 })
|
||||
run:new_line("mod.rs", { on_line = 2, text = "const Z: i32 = 1;", indent = 4 })
|
||||
run:new_line("mod.rs", { on_line = 6, text = "const Z: i32 = 1;", indent = 8 })
|
||||
run:new_line("mod.rs", { on_line = 7, text = "const Z: i32 = 1;", indent = 4 })
|
||||
run:new_line("string.rs", { on_line = 2, text = "brave new", indent = 0 })
|
||||
run:new_line("string.rs", { on_line = 5, text = "brave new \\", indent = 8 })
|
||||
run:new_line("string.rs", { on_line = 9, text = "brave new \\", indent = 8 })
|
||||
run:new_line("struct.rs", { on_line = 1, text = "z: i32,", indent = 4 })
|
||||
run:new_line("struct.rs", { on_line = 2, text = "z: i32,", indent = 4 })
|
||||
run:new_line("struct.rs", { on_line = 4, text = "let y = 1;", indent = 0 })
|
||||
run:new_line("trait.rs", { on_line = 4, text = "fn baz();", indent = 4 })
|
||||
run:new_line("trait.rs", { on_line = 5, text = "let y = 1;", indent = 0 })
|
||||
run:new_line("trait.rs", { on_line = 7, text = "fn baz();", indent = 4 })
|
||||
run:new_line("trait.rs", { on_line = 8, text = "()", indent = 8 })
|
||||
run:new_line("where.rs", { on_line = 17, text = "T: Debug,", indent = 4 })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue