aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorObserverOfTime <chronobserver@disroot.org>2022-09-26 19:25:26 +0300
committerChristian Clason <christian.clason@uni-due.de>2022-11-16 10:45:19 +0100
commita715e9331265a921281d0c1eb8281324ead41cbd (patch)
tree62b93b575559da9b9b82425d3f867e8fc82a2c96
parentUpdate lockfile.json (#3812) (diff)
downloadnvim-treesitter-a715e9331265a921281d0c1eb8281324ead41cbd.tar
nvim-treesitter-a715e9331265a921281d0c1eb8281324ead41cbd.tar.gz
nvim-treesitter-a715e9331265a921281d0c1eb8281324ead41cbd.tar.bz2
nvim-treesitter-a715e9331265a921281d0c1eb8281324ead41cbd.tar.lz
nvim-treesitter-a715e9331265a921281d0c1eb8281324ead41cbd.tar.xz
nvim-treesitter-a715e9331265a921281d0c1eb8281324ead41cbd.tar.zst
nvim-treesitter-a715e9331265a921281d0c1eb8281324ead41cbd.zip
feat: add awk
-rw-r--r--lua/nvim-treesitter/parsers.lua7
-rw-r--r--queries/awk/highlights.scm154
-rw-r--r--queries/awk/injections.scm2
3 files changed, 163 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 6d444cde1..e2e521224 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -1293,6 +1293,13 @@ list.vhs = {
filetype = "tape",
}
+list.awk = {
+ install_info = {
+ url = "https://github.com/Beaglefoot/tree-sitter-awk",
+ files = { "src/parser.c", "src/scanner.c" },
+ },
+}
+
local M = {
list = list,
filetype_to_parsername = filetype_to_parsername,
diff --git a/queries/awk/highlights.scm b/queries/awk/highlights.scm
new file mode 100644
index 000000000..918d0116e
--- /dev/null
+++ b/queries/awk/highlights.scm
@@ -0,0 +1,154 @@
+; adapted from https://github.com/Beaglefoot/tree-sitter-awk
+
+[
+ (identifier)
+ (field_ref)
+] @variable
+(field_ref (_) @variable)
+
+(number) @number
+
+(string) @string
+(regex) @string.regex
+(escape_sequence) @string.escape
+
+(comment) @comment @spell
+
+(ns_qualified_name (namespace) @namespace)
+(ns_qualified_name "::" @punctuation.delimiter)
+
+(func_def name: (_ (identifier) @function) @function)
+(func_call name: (_ (identifier) @function) @function)
+
+(func_def (param_list (identifier) @parameter))
+
+[
+ "print"
+ "printf"
+ "getline"
+] @function.builtin
+
+[
+ (delete_statement)
+ (break_statement)
+ (continue_statement)
+ (next_statement)
+ (nextfile_statement)
+] @keyword
+
+[
+ "func"
+ "function"
+] @keyword.function
+
+[
+ "return"
+ "exit"
+] @keyword.return
+
+[
+ "do"
+ "while"
+ "for"
+ "in"
+] @repeat
+
+[
+ "if"
+ "else"
+ "switch"
+ "case"
+ "default"
+] @conditional
+
+[
+ "@include"
+ "@load"
+] @include
+
+"@namespace" @preproc
+
+[
+ "BEGIN"
+ "END"
+ "BEGINFILE"
+ "ENDFILE"
+] @label
+
+(binary_exp [
+ "^"
+ "**"
+ "*"
+ "/"
+ "%"
+ "+"
+ "-"
+ "<"
+ ">"
+ "<="
+ ">="
+ "=="
+ "!="
+ "~"
+ "!~"
+ "in"
+ "&&"
+ "||"
+] @operator)
+
+(unary_exp [
+ "!"
+ "+"
+ "-"
+] @operator)
+
+(assignment_exp [
+ "="
+ "+="
+ "-="
+ "*="
+ "/="
+ "%="
+ "^="
+] @operator)
+
+(ternary_exp [
+ "?"
+ ":"
+] @operator)
+
+(update_exp [
+ "++"
+ "--"
+] @operator)
+
+(redirected_io_statement [
+ ">"
+ ">>"
+] @operator)
+
+(piped_io_statement [
+ "|"
+ "|&"
+] @operator)
+
+(piped_io_exp [
+ "|"
+ "|&"
+] @operator)
+
+(field_ref "$" @punctuation.delimiter)
+
+(regex "/" @punctuation.delimiter)
+(regex_constant "@" @punctuation.delimiter)
+
+[ ";" "," ] @punctuation.delimiter
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
diff --git a/queries/awk/injections.scm b/queries/awk/injections.scm
new file mode 100644
index 000000000..8cbffc623
--- /dev/null
+++ b/queries/awk/injections.scm
@@ -0,0 +1,2 @@
+(comment) @comment
+(regex) @regex