aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMunif Tanjim <hello@muniftanjim.dev>2022-01-21 18:00:02 +0600
committerChristian Clason <christian.clason@uni-due.de>2022-01-21 16:40:36 +0100
commit782e299cd6c926e0b5e438e154cac44a48c26a3c (patch)
treef0b9020f13dd48282aab8538ea259ce98de6e73a
parentfeat(indent): ecma - support try_catch and if_else (diff)
downloadnvim-treesitter-782e299cd6c926e0b5e438e154cac44a48c26a3c.tar
nvim-treesitter-782e299cd6c926e0b5e438e154cac44a48c26a3c.tar.gz
nvim-treesitter-782e299cd6c926e0b5e438e154cac44a48c26a3c.tar.bz2
nvim-treesitter-782e299cd6c926e0b5e438e154cac44a48c26a3c.tar.lz
nvim-treesitter-782e299cd6c926e0b5e438e154cac44a48c26a3c.tar.xz
nvim-treesitter-782e299cd6c926e0b5e438e154cac44a48c26a3c.tar.zst
nvim-treesitter-782e299cd6c926e0b5e438e154cac44a48c26a3c.zip
fix(indent): c/cpp - support newline after closing brace
-rw-r--r--queries/c/indents.scm2
-rw-r--r--tests/indent/c_spec.lua2
-rw-r--r--tests/indent/cpp_spec.lua2
3 files changed, 6 insertions, 0 deletions
diff --git a/queries/c/indents.scm b/queries/c/indents.scm
index fb9665fab..959678f6e 100644
--- a/queries/c/indents.scm
+++ b/queries/c/indents.scm
@@ -25,6 +25,8 @@
(binary_expression)
] @indent)
+(compound_statement "}" @indent_end)
+
[
"#define"
"#ifdef"
diff --git a/tests/indent/c_spec.lua b/tests/indent/c_spec.lua
index 4beaba761..5a7baa916 100644
--- a/tests/indent/c_spec.lua
+++ b/tests/indent/c_spec.lua
@@ -24,7 +24,9 @@ describe("indent C:", function()
runner:new_line("array.c", { on_line = 2, text = "0,", indent = 4 })
runner:new_line("compound_lit.c", { on_line = 7, text = ".z = 5,", indent = 8 })
runner:new_line("cond.c", { on_line = 3, text = "x++;", indent = 8 })
+ runner:new_line("cond.c", { on_line = 6, text = "x++;", indent = 8 })
runner:new_line("cond.c", { on_line = 8, text = "x++;", indent = 8 })
+ runner:new_line("cond.c", { on_line = 9, text = "x++;", indent = 4 })
runner:new_line("expr.c", { on_line = 10, text = "2 *", indent = 8 })
runner:new_line("func.c", { on_line = 17, text = "int z,", indent = 4 })
runner:new_line("label.c", { on_line = 3, text = "normal:", indent = 0 }, "expected failure", XFAIL)
diff --git a/tests/indent/cpp_spec.lua b/tests/indent/cpp_spec.lua
index 07adff52f..693279b89 100644
--- a/tests/indent/cpp_spec.lua
+++ b/tests/indent/cpp_spec.lua
@@ -31,7 +31,9 @@ describe("indent C++:", function()
-- TODO: find a clean way to import these from c_spec.lua
run:new_line("c/array.c", { on_line = 2, text = "0,", indent = 4 })
run:new_line("c/cond.c", { on_line = 3, text = "x++;", indent = 8 })
+ run:new_line("c/cond.c", { on_line = 6, text = "x++;", indent = 8 })
run:new_line("c/cond.c", { on_line = 8, text = "x++;", indent = 8 })
+ run:new_line("c/cond.c", { on_line = 9, text = "x++;", indent = 4 })
run:new_line("c/expr.c", { on_line = 10, text = "2 *", indent = 8 })
run:new_line("c/func.c", { on_line = 17, text = "int z,", indent = 4 })
run:new_line("c/label.c", { on_line = 3, text = "normal:", indent = 0 }, "expected failure", XFAIL)