on master help sign in
Add vhdl language support (#5826)

Simple highlight query file with keywords and builtin types matching. Many VHDL types however are defined in std libraries which do not currently get matched on. This is because the grammar doesn't consider them builtin types.

commit685ae2365a89346ef276dceb52c3cae40260d1fd authorTom Burdick <thomas.burdick@gmail.com> dateSat 25 Mar 2023, 12:10 (4 years ago) parent851ac6c
3 files changed+353
book/src/generated/lang-support.md+1 languages.toml+14 runtime/queries/vhdl/highlights.scm+338
book/src/generated/lang-support.md+1
@@ -145,6 +145,7 @@
145145| v | ✓ | ✓ | ✓ | `v` |
146146| vala | ✓ | | | `vala-language-server` |
147147| verilog | ✓ | ✓ | | `svlangserver` |
148+| vhdl | ✓ | | | `vhdl_ls` |
148149| vhs | ✓ | | | |
149150| vue | ✓ | | | `vls` |
150151| wast | ✓ | | | |
languages.toml+14
@@ -2369,3 +2369,17 @@ language-server = { command = "cs", args = ["launch", "com.disneystreaming.smith
23692369[[grammar]]
23702370name = "smithy"
23712371source = { git = "https://github.com/indoorvivants/tree-sitter-smithy", rev = "cf8c7eb9faf7c7049839585eac19c94af231e6a0" }
2372+
2373+[[language]]
2374+name = "vhdl"
2375+scope = "source.vhdl"
2376+file-types = ["vhd", "vhdl"]
2377+roots = []
2378+comment-token = "--"
2379+language-server = { command = "vhdl_ls", args = [] }
2380+indent = { tab-width = 2, unit = " " }
2381+injection-regex = "vhdl"
2382+
2383+[[grammar]]
2384+name = "vhdl"
2385+source = { git = "https://github.com/teburd/tree-sitter-vhdl", rev = "c57313adee2231100db0a7880033f6865deeadb2" }
runtime/queries/vhdl/highlights.scmnew file+338
@@ -0,0 +1,338 @@
1+(comment) @comment
2+
3+; Keywords
4+[
5+ ; vhdl 08
6+ "abs"
7+ "access"
8+ "after"
9+ "alias"
10+ "all"
11+ "and"
12+ "architecture"
13+ "array"
14+ "assert"
15+ "attribute"
16+ "begin"
17+ "block"
18+ "body"
19+ "buffer"
20+ "bus"
21+ "case"
22+ "component"
23+ "configuration"
24+ "constant"
25+ "disconnect"
26+ "downto"
27+ "else"
28+ "elsif"
29+ "end"
30+ "entity"
31+ "exit"
32+ "file"
33+ "for"
34+ "function"
35+ "generic"
36+ "group"
37+ "guarded"
38+ "if"
39+ "impure"
40+ "in"
41+ "inertial"
42+ "inout"
43+ "is"
44+ "label"
45+ "library"
46+ "linkage"
47+ "literal"
48+ "loop"
49+ "map"
50+ "mod"
51+ "nand"
52+ "new"
53+ "next"
54+ "nor"
55+ "not"
56+ "null"
57+ "of"
58+ "on"
59+ "open"
60+ "or"
61+ "others"
62+ "out"
63+ "package"
64+ "port"
65+ "postponed"
66+ "procedure"
67+ "process"
68+ "protected"
69+ "pure"
70+ "range"
71+ "record"
72+ "register"
73+ "reject"
74+ "rem"
75+ "report"
76+ "return"
77+ "rol"
78+ "ror"
79+ "select"
80+ "severity"
81+ "shared"
82+ "signal"
83+ "sla"
84+ "sll"
85+ "sra"
86+ "srl"
87+ "subtype"
88+ "then"
89+ "to"
90+ "transport"
91+ "type"
92+ "unaffected"
93+ "units"
94+ "until"
95+ "use"
96+ "variable"
97+ "wait"
98+ "when"
99+ "while"
100+ "with"
101+ "xnor"
102+ "xor"
103+ ; vhdl 08
104+ "context"
105+ "force"
106+ "property"
107+ "release"
108+ "sequence"
109+] @keyword
110+
111+[
112+ ; vhdl 02
113+ "boolean"
114+ "bit"
115+ "bit_vector"
116+ ;"character"
117+ ;"severity_level"
118+ ;"integer"
119+ ;"real"
120+ ;"time"
121+ ;"natural"
122+ ;"positive"
123+ "string"
124+ ;"line"
125+ ;"text"
126+ ;"side"
127+ ;"unsigned"
128+ ;"signed"
129+ ;"delay_length"
130+ ;"file_open_kind"
131+ ;"file_open_status"
132+ ;"std_logic"
133+ ;"std_logic_vector"
134+ ;"std_ulogic"
135+ ;"std_ulogic_vector"
136+ ; vhdl 08
137+ ;"boolean_vector"
138+ ;"integer_vector"
139+ ;"real_vector"
140+ ;"time_vector"
141+ ; math types
142+ ;"complex"
143+ ;"complex_polar"
144+ ;"positive_real"
145+ ;"principal_value"
146+] @type.builtin
147+
148+[
149+ ; vhdl 02
150+ "base"
151+ "left"
152+ "right"
153+ "high"
154+ "low"
155+ "pos"
156+ "val"
157+ "succ"
158+ "pred"
159+ "leftof"
160+ "rightof"
161+ "range"
162+ "reverse_range"
163+ "length"
164+ "delayed"
165+ "stable"
166+ "quiet"
167+ "transaction"
168+ "event"
169+ "active"
170+ "last_event"
171+ "last_active"
172+ "last_value"
173+ "driving"
174+ "driving_value"
175+ "ascending"
176+ "value"
177+ "image"
178+ "simple_name"
179+ "instance_name"
180+ "path_name"
181+ ;"foreign"
182+ ; vhdl 08
183+ "instance_name"
184+ "path_name"
185+] @attribute
186+
187+;[
188+ ; vhdl 02
189+ ;"now"
190+ ;"resolved"
191+ ;"rising_edge"
192+ ;"falling_edge"
193+ ;"read"
194+ ;"readline"
195+ ;"hread"
196+ ;"oread"
197+ ;"write"
198+ ;"writeline"
199+ ;"hwrite"
200+ ;"owrite"
201+ ;"endfile"
202+ ;"resize"
203+ ;"is_X"
204+ ;"std_match"
205+ ;"shift_left"
206+ ;"shift_right"
207+ ;"rotate_left"
208+ ;"rotate_right"
209+ ;"to_unsigned"
210+ ;"to_signed"
211+ ;"to_integer"
212+ ;"to_stdLogicVector"
213+ ;"to_stdULogic"
214+ ;"to_stdULogicVector"
215+ ;"to_bit"
216+ ;"to_bitVector"
217+ ;"to_X01"
218+ ;"to_X01Z"
219+ ;"to_UX01"
220+ ;"to_01"
221+ ;"conv_unsigned"
222+ ;"conv_signed"
223+ ;"conv_integer"
224+ ;"conv_std_logic_vector"
225+ ;"shl"
226+ ;"shr"
227+ ;"ext"
228+ ;"sxt"
229+ ;"deallocate"
230+ ; vhdl 08
231+ ;"finish"
232+ ;"flush"
233+ ;"justify"
234+ ;"maximum"
235+ ;"minimum"
236+ ;"resolution_limit"
237+ ;"stop"
238+ ;"swrite"
239+ ;"tee"
240+ ;"to_binarystring"
241+ ;"to_bstring"
242+ ;"to_hexstring"
243+ ;"to_hstring"
244+ ;"to_octalstring"
245+ ;"to_ostring"
246+ ;"to_string"
247+ ; vhdl math
248+ ;"arccos"
249+ ;"arccosh"
250+ ;"arcsin"
251+ ;"arcsinh"
252+ ;"arctan"
253+ ;"arctanh"
254+ ;"arg"
255+ ;"cbrt"
256+ ;"ceil"
257+ ;"cmplx"
258+ ;"complex_to_polar"
259+ ;"conj"
260+ ;"cos"
261+ ;"cosh"
262+ ;"exp"
263+ ;"floor"
264+ ;"get_principal_value"
265+ ;"log"
266+ ;"log10"
267+ ;"log2"
268+ ;"polar_to_complex"
269+ ;"realmax"
270+ ;"realmin"
271+ ;"round"
272+ ;"sign"
273+ ;"sin"
274+ ;"sinh"
275+ ;"sqrt"
276+ ;"tan"
277+ ;"tanh"
278+ ;"trunc"
279+ ;"uniform"
280+;] @function.builtin
281+
282+; Operators
283+[
284+ "+"
285+ "-"
286+ "*"
287+ "/"
288+ "**"
289+ "abs"
290+ "not"
291+ "mod"
292+ "rem"
293+ "&"
294+ "sll"
295+ "srl"
296+ "sla"
297+ "sra"
298+ "rol"
299+ "ror"
300+ "="
301+ "/="
302+ "?="
303+ "?/="
304+ "?<"
305+ "?<="
306+ "?>"
307+ "?>="
308+ "<"
309+ "<="
310+ ">"
311+ ">="
312+ "and"
313+ "or"
314+ "nand"
315+ "nor"
316+ "xor"
317+ "xnor"
318+ ":="
319+ "<="
320+ "??"
321+] @operator
322+
323+[
324+ ";"
325+ ","
326+] @punctuation.delimiter
327+
328+[
329+ "("
330+ ")"
331+ "'"
332+] @punctuation.bracket
333+
334+(full_type_declaration "type" name: (identifier) @type)
335+(signal_declaration "signal" (identifier_list) @variable)
336+(variable_declaration "variable" (identifier_list) @variable)
337+(constant_declaration "constant" (identifier_list) @variable)
338+