on master help sign in
Lua support (#665)
ae3f936oberblastmeister
.gitmodules+4
@@ -102,6 +102,10 @@
102 path = helix-syntax/languages/tree-sitter-protobuf
102 path = helix-syntax/languages/tree-sitter-protobuf
103 url = https://github.com/yusdacra/tree-sitter-protobuf.git
103 url = https://github.com/yusdacra/tree-sitter-protobuf.git
104 shallow = true
104 shallow = true
105+[submodule "helix-syntax/languages/tree-sitter-lua"]
106+ path = helix-syntax/languages/tree-sitter-lua
107+ url = https://github.com/nvim-treesitter/tree-sitter-lua
108+ shallow = true
105[submodule "helix-syntax/languages/tree-sitter-yaml"]
109[submodule "helix-syntax/languages/tree-sitter-yaml"]
106 path = helix-syntax/languages/tree-sitter-yaml
110 path = helix-syntax/languages/tree-sitter-yaml
107 url = https://github.com/ikatyang/tree-sitter-yaml
111 url = https://github.com/ikatyang/tree-sitter-yaml
helix-syntax/languages/tree-sitter-luanew file+1

Submodule changed.

languages.toml+8
@@ -224,6 +224,14 @@ roots = []
224comment-token = ";"
224comment-token = ";"
225indent = { tab-width = 4, unit = " " }
225indent = { tab-width = 4, unit = " " }
226
226
227+[[language]]
228+name = "lua"
229+scope = "source.lua"
230+file-types = ["lua"]
231+roots = []
232+comment-token = "--"
233+indent = { tab-width = 2, unit = " " }
234+
227[[language]]
235[[language]]
228name = "yaml"
236name = "yaml"
229scope = "source.yaml"
237scope = "source.yaml"
runtime/queries/lua/highlights.scmnew file+166
@@ -0,0 +1,166 @@
1+;;; Highlighting for lua
2+
3+;;; Builtins
4+(self) @variable.builtin
5+
6+;; Keywords
7+
8+(if_statement
9+[
10+ "if"
11+ "then"
12+ "end"
13+] @keyword.control.conditional)
14+
15+[
16+ "else"
17+ "elseif"
18+ "then"
19+] @keyword.control.conditional
20+
21+(for_statement
22+[
23+ "for"
24+ "do"
25+ "end"
26+] @keyword.control.loop)
27+
28+(for_in_statement
29+[
30+ "for"
31+ "do"
32+ "end"
33+] @keyword.control.loop)
34+
35+(while_statement
36+[
37+ "while"
38+ "do"
39+ "end"
40+] @keyword.control.loop)
41+
42+(repeat_statement
43+[
44+ "repeat"
45+ "until"
46+] @keyword.control.loop)
47+
48+(do_statement
49+[
50+ "do"
51+ "end"
52+] @keyword)
53+
54+[
55+ "in"
56+ "local"
57+ (break_statement)
58+ "goto"
59+ "return"
60+] @keyword
61+
62+;; Operators
63+
64+[
65+ "not"
66+ "and"
67+ "or"
68+] @keyword.operator
69+
70+[
71+"="
72+"~="
73+"=="
74+"<="
75+">="
76+"<"
77+">"
78+"+"
79+"-"
80+"%"
81+"/"
82+"//"
83+"*"
84+"^"
85+"&"
86+"~"
87+"|"
88+">>"
89+"<<"
90+".."
91+"#"
92+ ] @operator
93+
94+;; Punctuation
95+["," "." ":" ";"] @punctuation.delimiter
96+
97+;; Brackets
98+[
99+ "("
100+ ")"
101+ "["
102+ "]"
103+ "{"
104+ "}"
105+] @punctuation.bracket
106+
107+; ;; Constants
108+[
109+(false)
110+(true)
111+] @boolean
112+(nil) @constant.builtin
113+(spread) @constant ;; "..."
114+((identifier) @constant
115+ (#match? @constant "^[A-Z][A-Z_0-9]*$"))
116+
117+;; Parameters
118+(parameters
119+ (identifier) @parameter)
120+
121+; ;; Functions
122+(function [(function_name) (identifier)] @function)
123+(function ["function" "end"] @keyword.function)
124+
125+(function
126+ (function_name
127+ (function_name_field
128+ (property_identifier) @function .)))
129+
130+(local_function (identifier) @function)
131+(local_function ["function" "end"] @keyword.function)
132+
133+(variable_declaration
134+ (variable_declarator (identifier) @function) (function_definition))
135+(local_variable_declaration
136+ (variable_declarator (identifier) @function) (function_definition))
137+
138+(function_definition ["function" "end"] @keyword.function)
139+
140+(function_call
141+ [
142+ ((identifier) @variable (method) @method)
143+ ((_) (method) @method)
144+ (identifier) @function
145+ (field_expression (property_identifier) @function)
146+ ]
147+ . (arguments))
148+
149+;; Nodes
150+(table ["{" "}"] @constructor)
151+(comment) @comment
152+(string) @string
153+(number) @number
154+(label_statement) @label
155+; A bit of a tricky one, this will only match field names
156+(field . (identifier) @property (_))
157+(shebang) @comment
158+
159+;; Property
160+(property_identifier) @property
161+
162+;; Variable
163+(identifier) @variable
164+
165+;; Error
166+(ERROR) @error
runtime/queries/lua/indents.tomlnew file+24
@@ -0,0 +1,24 @@
1+indent = [
2+ "function_definition",
3+ "variable_declaration",
4+ "local_variable_declaration",
5+ "field",
6+ "local_function",
7+ "function",
8+ "if_statement",
9+ "for_statement",
10+ "for_in_statement",
11+ "repeat_statement",
12+ "return_statement",
13+ "while_statement",
14+ "table",
15+ "arguments",
16+ "do_statement",
17+]
18+
19+oudent = [
20+ "end",
21+ "until",
22+ "}",
23+ ")",
24+]