blob: 6c2bab7badb60e096574be8b930fde9b51cdb904 [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
6
7if exists("b:current_syntax")
8 finish
9endif
10let b:current_syntax = "gleam"
11
12syntax case match
13
14" Keywords
15syntax keyword gleamConditional case if
16syntax keyword gleamConstant const
17syntax keyword gleamDebug echo
18syntax keyword gleamException panic assert todo
19syntax keyword gleamInclude import
20syntax keyword gleamKeyword as let use
21syntax keyword gleamStorageClass pub opaque
22syntax keyword gleamType type
23
24" Number
25"" Int
26syntax match gleamNumber "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\>"
27
28"" Binary
29syntax match gleamNumber "\<-\=0[bB]_\?\%([01]\|[01]_[01]\)\+\>"
30
31"" Octet
32syntax match gleamNumber "\<-\=0[oO]\?_\?\%(\o\|\o_\o\)\+\>"
33
34"" Hexadecimal
35syntax match gleamNumber "\<-\=0[xX]_\?\%(\x\|\x_\x\)\+\>"
36
37"" Float
38syntax match gleamFloat "\(0*[1-9][0-9_]*\|0\)\.\(0*[1-9][0-9_]*\|0\)\(e-\=0*[1-9][0-9_]*\)\="
39
40" String
41syntax region gleamString start=/"/ end=/"/ contains=gleamSpecial
42syntax match gleamSpecial '\\.' contained
43
44" Operators
45"" Basic
46syntax match gleamOperator "[-+/*]\.\=\|[%=]"
47
48"" Arrows + Pipeline
49syntax match gleamOperator "<-\|[-|]>"
50
51"" Bool
52syntax match gleamOperator "&&\|||"
53
54"" Comparison
55syntax match gleamOperator "[<>]=\=\.\=\|[=!]="
56
57"" Misc
58syntax match gleamOperator "\.\.\|<>\||"
59
60" Type
61syntax match gleamIdentifier "\<[A-Z][a-zA-Z0-9]*\>"
62
63" Attribute
64syntax match gleamPreProc "@[a-z][a-z_]*"
65
66" Function definition
67syntax keyword gleamKeyword fn nextgroup=gleamFunction skipwhite skipempty
68syntax match gleamFunction "[a-z][a-z0-9_]*\ze\s*(" skipwhite skipnl
69
70" Comments
71syntax region gleamComment start="//" end="$" contains=gleamTodo
72syntax region gleamSpecialComment start="///" end="$"
73syntax region gleamSpecialComment start="////" end="$"
74syntax keyword gleamTodo contained TODO FIXME XXX NB NOTE
75
76" Highlight groups
77highlight link gleamComment Comment
78highlight link gleamConditional Conditional
79highlight link gleamConstant Constant
80highlight link gleamDebug Debug
81highlight link gleamException Exception
82highlight link gleamFloat Float
83highlight link gleamFunction Function
84highlight link gleamIdentifier Identifier
85highlight link gleamInclude Include
86highlight link gleamKeyword Keyword
87highlight link gleamNumber Number
88highlight link gleamOperator Operator
89highlight link gleamPreProc PreProc
90highlight link gleamSpecial Special
91highlight link gleamSpecialComment SpecialComment
92highlight link gleamStorageClass StorageClass
93highlight link gleamString String
94highlight link gleamTodo Todo
95highlight link gleamType Type
96
97" vim: sw=2 sts=2 et