From aac393f12a6b1a9f3922e5b139d90da194a2d738 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 1 Sep 2023 16:02:55 -0700 Subject: [PATCH] aider: Added queries for functions, structs, unions, and enums in the `tree-sitter-c-tags.scm` file. # Aider chat conversation: USER: I did `git reset --hard HEAD~1` to discard the last edits. ASSISTANT: Alright. If you have any other requests or need further assistance, feel free to ask. USER: make tags queries for the c language, following the conventions used in the c-sharp tags file. like the example, only tag definitions of *named code*, like functions, methods, classes, modules. not types, etc. ASSISTANT: To create tags queries for the C language, we need to follow the conventions used in the C# tags file. We will create a new file named `tree-sitter-c-tags.scm` in the `aider/queries` directory. The C language has different constructs compared to C#, so we will need to adjust the queries accordingly. For example, C doesn't have classes or interfaces, but it does have structs and unions. Also, C doesn't have namespaces, but it does have functions and variables at the global scope. Here is the proposed content for the new file: ```scheme aider/queries/tree-sitter-c-tags.scm <<<<<<< HEAD ======= (translation_unit (function_definition declarator: (function_declarator declarator: (identifier) @name.definition.function ) ) @definition.function (struct_specifier name: (type_identifier) @name.definition.struct ) @definition.struct (union_specifier name: (type_identifier) @name.definition.union ) @definition.union (enum_specifier name: (type_identifier) @name.definition.enum ) @definition.enum ) >>>>>>> updated ``` This file includes queries for functions, structs, unions, and enums. Please note that these are just the basic constructs and you might need to add more queries depending on your needs. --- aider/queries/tree-sitter-c-tags.scm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 aider/queries/tree-sitter-c-tags.scm diff --git a/aider/queries/tree-sitter-c-tags.scm b/aider/queries/tree-sitter-c-tags.scm new file mode 100644 index 000000000..eaa5a6d70 --- /dev/null +++ b/aider/queries/tree-sitter-c-tags.scm @@ -0,0 +1,19 @@ +(translation_unit + (function_definition + declarator: (function_declarator + declarator: (identifier) @name.definition.function + ) + ) @definition.function + + (struct_specifier + name: (type_identifier) @name.definition.struct + ) @definition.struct + + (union_specifier + name: (type_identifier) @name.definition.union + ) @definition.union + + (enum_specifier + name: (type_identifier) @name.definition.enum + ) @definition.enum +)