blob: e89ab564e908ab92a0545b6ed6b09f42f002a9fb [file] [log] [blame]
Kirill Morozov32f49732025-04-24 21:28:56 +02001" Vim syntax file
2" Language: Gleam
3" Maintainer: Kirill Morozov <kirill@robotix.pro>
4" Based On: https://github.com/gleam-lang/gleam.vim
5" Last Change: 2025 Apr 20
Kat6451e5f2025-05-15 20:10:48 +02006" 2025 May 15 Add @Spell clusters #17324
Kirill Morozov32f49732025-04-24 21:28:56 +02007
8if exists("b:current_syntax")
9 finish
10endif
11let b:current_syntax = "gleam"
12
13syntax case match
14
15" Keywords
16syntax keyword gleamConditional case if
17syntax keyword gleamConstant const
18syntax keyword gleamDebug echo
19syntax keyword gleamException panic assert todo
20syntax keyword gleamInclude import
21syntax keyword gleamKeyword as let use
22syntax keyword gleamStorageClass pub opaque
23syntax keyword gleamType type
24
25" Number
26"" Int
27syntax match gleamNumber "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\>"
28
29"" Binary
30syntax match gleamNumber "\<-\=0[bB]_\?\%([01]\|[01]_[01]\)\+\>"
31
32"" Octet
33syntax match gleamNumber "\<-\=0[oO]\?_\?\%(\o\|\o_\o\)\+\>"
34
35"" Hexadecimal
36syntax match gleamNumber "\<-\=0[xX]_\?\%(\x\|\x_\x\)\+\>"
37
38"" Float
39syntax match gleamFloat "\(0*[1-9][0-9_]*\|0\)\.\(0*[1-9][0-9_]*\|0\)\(e-\=0*[1-9][0-9_]*\)\="
40
41" String
Kat6451e5f2025-05-15 20:10:48 +020042syntax region gleamString start=/"/ end=/"/ contains=gleamSpecial,@Spell
Kirill Morozov32f49732025-04-24 21:28:56 +020043syntax match gleamSpecial '\\.' contained
44
45" Operators
46"" Basic
47syntax match gleamOperator "[-+/*]\.\=\|[%=]"
48
49"" Arrows + Pipeline
50syntax match gleamOperator "<-\|[-|]>"
51
52"" Bool
53syntax match gleamOperator "&&\|||"
54
55"" Comparison
56syntax match gleamOperator "[<>]=\=\.\=\|[=!]="
57
58"" Misc
59syntax match gleamOperator "\.\.\|<>\||"
60
61" Type
Kat6451e5f2025-05-15 20:10:48 +020062syntax match gleamIdentifier "\<[A-Z][a-zA-Z0-9]*\>" contains=@NoSpell
Kirill Morozov32f49732025-04-24 21:28:56 +020063
64" Attribute
Kat6451e5f2025-05-15 20:10:48 +020065syntax match gleamPreProc "@[a-z][a-z_]*" contains=@NoSpell
Kirill Morozov32f49732025-04-24 21:28:56 +020066
67" Function definition
68syntax keyword gleamKeyword fn nextgroup=gleamFunction skipwhite skipempty
Kat6451e5f2025-05-15 20:10:48 +020069syntax match gleamFunction "[a-z][a-z0-9_]*\ze\s*(" skipwhite skipnl contains=@NoSpell
Kirill Morozov32f49732025-04-24 21:28:56 +020070
71" Comments
Kat6451e5f2025-05-15 20:10:48 +020072syntax region gleamComment start="//" end="$" contains=gleamTodo,@Spell
73syntax region gleamSpecialComment start="///" end="$" contains=@Spell
74syntax region gleamSpecialComment start="////" end="$" contains=@Spell
Kirill Morozov32f49732025-04-24 21:28:56 +020075syntax keyword gleamTodo contained TODO FIXME XXX NB NOTE
76
77" Highlight groups
78highlight link gleamComment Comment
79highlight link gleamConditional Conditional
80highlight link gleamConstant Constant
81highlight link gleamDebug Debug
82highlight link gleamException Exception
83highlight link gleamFloat Float
84highlight link gleamFunction Function
85highlight link gleamIdentifier Identifier
86highlight link gleamInclude Include
87highlight link gleamKeyword Keyword
88highlight link gleamNumber Number
89highlight link gleamOperator Operator
90highlight link gleamPreProc PreProc
91highlight link gleamSpecial Special
92highlight link gleamSpecialComment SpecialComment
93highlight link gleamStorageClass StorageClass
94highlight link gleamString String
95highlight link gleamTodo Todo
96highlight link gleamType Type
97
98" vim: sw=2 sts=2 et