on master help sign in
AWK support (#3528)
commit45add73fb1d2c4f2b0c544117c2d83b7081a2a4a authorath3 <45574139+ath3@users.noreply.github.com> dateWed 24 Aug 2022, 18:58 (4 years ago) parentfacde9f
6 files changed+155
book/src/generated/lang-support.md+1 languages.toml+14 runtime/queries/awk/highlights.scm+122 runtime/queries/awk/injections.scm+2 runtime/queries/awk/textobjects.scm+10 runtime/queries/bash/injections.scm+6
book/src/generated/lang-support.md+1
@@ -1,5 +1,6 @@
11| Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP |
22| --- | --- | --- | --- | --- |
3+| awk | ✓ | ✓ | | `awk-language-server` |
34| bash | ✓ | | | `bash-language-server` |
45| beancount | ✓ | | | |
56| c | ✓ | ✓ | ✓ | `clangd` |
languages.toml+14
@@ -66,6 +66,20 @@ indent = { tab-width = 2, unit = " " }
6666name = "toml"
6767source = { git = "https://github.com/ikatyang/tree-sitter-toml", rev = "7cff70bbcbbc62001b465603ca1ea88edd668704" }
6868
69+[[language]]
70+name = "awk"
71+scope = "source.awk"
72+injection-regex = "awk"
73+file-types = ["awk", "gawk", "nawk", "mawk"]
74+roots = []
75+comment-token = "#"
76+language-server = { command = "awk-language-server" }
77+indent = { tab-width = 2, unit = " " }
78+
79+[[grammar]]
80+name = "awk"
81+source = { git = "https://github.com/Beaglefoot/tree-sitter-awk", rev = "a799bc5da7c2a84bc9a06ba5f3540cf1191e4ee3" }
82+
6983[[language]]
7084name = "protobuf"
7185scope = "source.proto"
runtime/queries/awk/highlights.scmnew file+122
@@ -0,0 +1,122 @@
1+; tree-sitter-awk v0.5.1
2+
3+; https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries
4+
5+; Order matters
6+
7+[
8+ ";"
9+ ","
10+ "("
11+ ")"
12+ "["
13+ "]"
14+ "{"
15+ "}"
16+] @operator
17+
18+(piped_io_statement [
19+ "|"
20+ "|&"
21+] @operator)
22+
23+(redirected_io_statement [
24+ ">"
25+ ">>"
26+] @operator)
27+
28+(update_exp [
29+ "++"
30+ "--"
31+] @operator)
32+
33+(ternary_exp [
34+ "?"
35+ ":"
36+] @operator)
37+
38+(assignment_exp [
39+ "="
40+ "+="
41+ "-="
42+ "*="
43+ "/="
44+ "%="
45+ "^="
46+] @operator)
47+
48+(unary_exp [
49+ "!"
50+ "+"
51+ "-"
52+] @operator)
53+
54+(binary_exp [
55+ "^"
56+ "**"
57+ "*"
58+ "/"
59+ "%"
60+ "+"
61+ "-"
62+ "<"
63+ ">"
64+ "<="
65+ ">="
66+ "=="
67+ "!="
68+ "~"
69+ "!~"
70+ "in"
71+ "&&"
72+ "||"
73+] @operator)
74+
75+[
76+ "@include"
77+ "@load"
78+ "@namespace"
79+ (pattern)
80+] @namespace
81+
82+[
83+ "function"
84+ "func"
85+ "print"
86+ "printf"
87+ "if"
88+ "else"
89+ "do"
90+ "while"
91+ "for"
92+ "in"
93+ "delete"
94+ "return"
95+ "exit"
96+ "switch"
97+ "case"
98+ "default"
99+ (break_statement)
100+ (continue_statement)
101+ (next_statement)
102+ (nextfile_statement)
103+ (getline_input)
104+ (getline_file)
105+] @keyword
106+
107+(comment) @comment
108+(regex) @string.regexp
109+(number) @constant.numeric
110+(string) @string
111+
112+(func_call name: (identifier) @function)
113+(func_def name: (identifier) @function)
114+
115+(field_ref (_) @variable)
116+[
117+ (identifier)
118+ (field_ref)
119+] @variable
120+
121+(ns_qualified_name "::" @operator)
122+(ns_qualified_name (namespace) @namespace)
runtime/queries/awk/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/awk/textobjects.scmnew file+10
@@ -0,0 +1,10 @@
1+
2+(func_def name: (identifier) (block) @function.inside) @function.around
3+
4+(param_list (_) @parameter.inside) @parameter.around
5+
6+(args (_) @parameter.inside) @parameter.around
7+
8+(comment) @comment.inside
9+
10+(comment)+ @comment.around
runtime/queries/bash/injections.scm+6
@@ -1,2 +1,8 @@
11((comment) @injection.content
22 (#set! injection.language "comment"))
3+
4+(command
5+ name: (command_name (word) @_command)
6+ argument: (raw_string) @injection.content
7+ (#match? @_command "^[gnm]?awk$")
8+ (#set! injection.language "awk"))