summaryrefslogtreecommitdiff
path: root/runtime/queries/c
diff options
context:
space:
mode:
authorSebastian Neubauer2022-01-04 01:53:04 +0000
committerGitHub2022-01-04 01:53:04 +0000
commit5b1a628e81b7d2f198ef401d442ca7967c5a0135 (patch)
tree380f8a9f0b61d2c5945496458821c73ec285de98 /runtime/queries/c
parent641255ccc83648d164bf6e8e8e4e93460591830b (diff)
Add textobjects and indents to c and cpp (#1293)
Indentation of single line statements doesn't work, i.e. for (;;)<hit enter> leads to for(;;) <cursor here> Only blocks with curly braces are indented.
Diffstat (limited to 'runtime/queries/c')
-rw-r--r--runtime/queries/c/indents.toml16
-rw-r--r--runtime/queries/c/textobjects.scm13
2 files changed, 29 insertions, 0 deletions
diff --git a/runtime/queries/c/indents.toml b/runtime/queries/c/indents.toml
new file mode 100644
index 00000000..f4076e17
--- /dev/null
+++ b/runtime/queries/c/indents.toml
@@ -0,0 +1,16 @@
+indent = [
+ "compound_statement",
+ "field_declaration_list",
+ "enumerator_list",
+ "parameter_list",
+ "init_declarator",
+ "case_statement",
+ "condition_clause",
+ "expression_statement",
+]
+
+outdent = [
+ "case",
+ "}",
+ "]",
+]
diff --git a/runtime/queries/c/textobjects.scm b/runtime/queries/c/textobjects.scm
new file mode 100644
index 00000000..b0f03668
--- /dev/null
+++ b/runtime/queries/c/textobjects.scm
@@ -0,0 +1,13 @@
+(function_definition
+ body: (_) @function.inside) @function.around
+
+(struct_specifier
+ body: (_) @class.inside) @class.around
+
+(enum_specifier
+ body: (_) @class.inside) @class.around
+
+(union_specifier
+ body: (_) @class.inside) @class.around
+
+(parameter_declaration) @parameter.inside