aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/awk
diff options
context:
space:
mode:
authorath32022-08-24 16:58:15 +0000
committerGitHub2022-08-24 16:58:15 +0000
commit45add73fb1d2c4f2b0c544117c2d83b7081a2a4a (patch)
tree795d28d0d078917051383ae66250076596393320 /runtime/queries/awk
parentfacde9f18c03dd8061199215af5a010903daaedb (diff)
AWK support (#3528)
Diffstat (limited to 'runtime/queries/awk')
-rw-r--r--runtime/queries/awk/highlights.scm122
-rw-r--r--runtime/queries/awk/injections.scm2
-rw-r--r--runtime/queries/awk/textobjects.scm10
3 files changed, 134 insertions, 0 deletions
diff --git a/runtime/queries/awk/highlights.scm b/runtime/queries/awk/highlights.scm
new file mode 100644
index 00000000..34d660ad
--- /dev/null
+++ b/runtime/queries/awk/highlights.scm
@@ -0,0 +1,122 @@
+; tree-sitter-awk v0.5.1
+
+; https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries
+
+; Order matters
+
+[
+ ";"
+ ","
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @operator
+
+(piped_io_statement [
+ "|"
+ "|&"
+] @operator)
+
+(redirected_io_statement [
+ ">"
+ ">>"
+] @operator)
+
+(update_exp [
+ "++"
+ "--"
+] @operator)
+
+(ternary_exp [
+ "?"
+ ":"
+] @operator)
+
+(assignment_exp [
+ "="
+ "+="
+ "-="
+ "*="
+ "/="
+ "%="
+ "^="
+] @operator)
+
+(unary_exp [
+ "!"
+ "+"
+ "-"
+] @operator)
+
+(binary_exp [
+ "^"
+ "**"
+ "*"
+ "/"
+ "%"
+ "+"
+ "-"
+ "<"
+ ">"
+ "<="
+ ">="
+ "=="
+ "!="
+ "~"
+ "!~"
+ "in"
+ "&&"
+ "||"
+] @operator)
+
+[
+ "@include"
+ "@load"
+ "@namespace"
+ (pattern)
+] @namespace
+
+[
+ "function"
+ "func"
+ "print"
+ "printf"
+ "if"
+ "else"
+ "do"
+ "while"
+ "for"
+ "in"
+ "delete"
+ "return"
+ "exit"
+ "switch"
+ "case"
+ "default"
+ (break_statement)
+ (continue_statement)
+ (next_statement)
+ (nextfile_statement)
+ (getline_input)
+ (getline_file)
+] @keyword
+
+(comment) @comment
+(regex) @string.regexp
+(number) @constant.numeric
+(string) @string
+
+(func_call name: (identifier) @function)
+(func_def name: (identifier) @function)
+
+(field_ref (_) @variable)
+[
+ (identifier)
+ (field_ref)
+] @variable
+
+(ns_qualified_name "::" @operator)
+(ns_qualified_name (namespace) @namespace)
diff --git a/runtime/queries/awk/injections.scm b/runtime/queries/awk/injections.scm
new file mode 100644
index 00000000..321c90ad
--- /dev/null
+++ b/runtime/queries/awk/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/awk/textobjects.scm b/runtime/queries/awk/textobjects.scm
new file mode 100644
index 00000000..467a8982
--- /dev/null
+++ b/runtime/queries/awk/textobjects.scm
@@ -0,0 +1,10 @@
+
+(func_def name: (identifier) (block) @function.inside) @function.around
+
+(param_list (_) @parameter.inside) @parameter.around
+
+(args (_) @parameter.inside) @parameter.around
+
+(comment) @comment.inside
+
+(comment)+ @comment.around