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