aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries
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
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')
-rw-r--r--runtime/queries/c/indents.toml16
-rw-r--r--runtime/queries/c/textobjects.scm13
-rw-r--r--runtime/queries/cpp/indents.toml17
-rw-r--r--runtime/queries/cpp/textobjects.scm7
4 files changed, 53 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
diff --git a/runtime/queries/cpp/indents.toml b/runtime/queries/cpp/indents.toml
new file mode 100644
index 00000000..0ca2ed8b
--- /dev/null
+++ b/runtime/queries/cpp/indents.toml
@@ -0,0 +1,17 @@
+indent = [
+ "compound_statement",
+ "field_declaration_list",
+ "enumerator_list",
+ "parameter_list",
+ "init_declarator",
+ "case_statement",
+ "condition_clause",
+ "expression_statement",
+]
+
+outdent = [
+ "case",
+ "access_specifier",
+ "}",
+ "]",
+]
diff --git a/runtime/queries/cpp/textobjects.scm b/runtime/queries/cpp/textobjects.scm
new file mode 100644
index 00000000..6e3de1a2
--- /dev/null
+++ b/runtime/queries/cpp/textobjects.scm
@@ -0,0 +1,7 @@
+; inherits: c
+
+(lambda_expression
+ body: (_) @function.inside) @function.around
+
+(class_specifier
+ body: (_) @class.inside) @class.around