29996
|
1 " Vim syntax file for Godot gdscript
|
|
2 " Language: gdscript
|
|
3 " Maintainer: Maxim Kim <habamax@gmail.com>
|
30085
|
4 " Website: https://github.com/habamax/vim-gdscript
|
29996
|
5 " Filenames: *.gd
|
|
6
|
|
7 if exists("b:current_syntax")
|
|
8 finish
|
|
9 endif
|
|
10
|
30085
|
11 let s:keepcpo = &cpo
|
29996
|
12 set cpo&vim
|
|
13
|
|
14 syntax sync maxlines=100
|
|
15
|
|
16 syn keyword gdscriptConditional if else elif match
|
|
17 syn keyword gdscriptRepeat for while break continue
|
|
18
|
|
19 syn keyword gdscriptOperator is as not and or in
|
|
20
|
|
21 syn match gdscriptBlockStart ":\s*$"
|
|
22
|
|
23 syn keyword gdscriptKeyword null self owner parent tool
|
|
24 syn keyword gdscriptBoolean false true
|
|
25
|
|
26 syn keyword gdscriptStatement remote master puppet remotesync mastersync puppetsync sync
|
|
27 syn keyword gdscriptStatement return pass
|
|
28 syn keyword gdscriptStatement static const enum
|
|
29 syn keyword gdscriptStatement breakpoint assert
|
|
30 syn keyword gdscriptStatement onready
|
|
31 syn keyword gdscriptStatement class_name extends
|
|
32
|
|
33 syn keyword gdscriptType void bool int float String contained
|
30324
|
34 syn match gdscriptType ":\s*\zs\h\w*" contained
|
|
35 syn match gdscriptType "->\s*\zs\h\w*" contained
|
29996
|
36
|
|
37 syn keyword gdscriptStatement var nextgroup=gdscriptTypeDecl skipwhite
|
|
38 syn keyword gdscriptStatement const nextgroup=gdscriptTypeDecl skipwhite
|
30324
|
39 syn match gdscriptTypeDecl "\h\w*\s*:\s*\h\w*" contains=gdscriptType contained skipwhite
|
|
40 syn match gdscriptTypeDecl "->\s*\h\w*" contains=gdscriptType skipwhite
|
29996
|
41
|
|
42 syn keyword gdscriptStatement export nextgroup=gdscriptExportTypeDecl skipwhite
|
30324
|
43 syn match gdscriptExportTypeDecl "(.\{-}[,)]" contains=gdscriptOperator,gdscriptType contained skipwhite
|
29996
|
44
|
|
45 syn keyword gdscriptStatement setget nextgroup=gdscriptSetGet,gdscriptSetGetSeparator skipwhite
|
|
46 syn match gdscriptSetGet "\h\w*" nextgroup=gdscriptSetGetSeparator display contained skipwhite
|
|
47 syn match gdscriptSetGetSeparator "," nextgroup=gdscriptSetGet display contained skipwhite
|
|
48
|
|
49 syn keyword gdscriptStatement class func signal nextgroup=gdscriptFunctionName skipwhite
|
|
50 syn match gdscriptFunctionName "\h\w*" nextgroup=gdscriptFunctionParams display contained skipwhite
|
|
51 syn match gdscriptFunctionParams "(.*)" contains=gdscriptTypeDecl display contained skipwhite
|
|
52
|
|
53 syn match gdscriptNode "\$\h\w*\%(/\h\w*\)*"
|
|
54
|
|
55 syn match gdscriptComment "#.*$" contains=@Spell,gdscriptTodo
|
|
56
|
|
57 syn region gdscriptString matchgroup=gdscriptQuotes
|
|
58 \ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
|
|
59 \ contains=gdscriptEscape,@Spell
|
|
60
|
|
61 syn region gdscriptString matchgroup=gdscriptTripleQuotes
|
|
62 \ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
|
|
63 \ contains=gdscriptEscape,@Spell
|
|
64
|
|
65 syn match gdscriptEscape +\\[abfnrtv'"\\]+ contained
|
|
66 syn match gdscriptEscape "\\$"
|
|
67
|
|
68 " Numbers
|
|
69 syn match gdscriptNumber "\<0x\%(_\=\x\)\+\>"
|
|
70 syn match gdscriptNumber "\<0b\%(_\=[01]\)\+\>"
|
|
71 syn match gdscriptNumber "\<\d\%(_\=\d\)*\>"
|
|
72 syn match gdscriptNumber "\<\d\%(_\=\d\)*\%(e[+-]\=\d\%(_\=\d\)*\)\=\>"
|
|
73 syn match gdscriptNumber "\<\d\%(_\=\d\)*\.\%(e[+-]\=\d\%(_\=\d\)*\)\=\%(\W\|$\)\@="
|
|
74 syn match gdscriptNumber "\%(^\|\W\)\@1<=\%(\d\%(_\=\d\)*\)\=\.\d\%(_\=\d\)*\%(e[+-]\=\d\%(_\=\d\)*\)\=\>"
|
|
75
|
|
76 " XXX, TODO, etc
|
|
77 syn keyword gdscriptTodo TODO XXX FIXME HACK NOTE BUG contained
|
|
78
|
|
79 hi def link gdscriptStatement Statement
|
|
80 hi def link gdscriptKeyword Keyword
|
|
81 hi def link gdscriptConditional Conditional
|
|
82 hi def link gdscriptBoolean Boolean
|
|
83 hi def link gdscriptOperator Operator
|
|
84 hi def link gdscriptRepeat Repeat
|
|
85 hi def link gdscriptSetGet Function
|
|
86 hi def link gdscriptFunctionName Function
|
|
87 hi def link gdscriptBuiltinStruct Typedef
|
|
88 hi def link gdscriptComment Comment
|
|
89 hi def link gdscriptString String
|
|
90 hi def link gdscriptQuotes String
|
|
91 hi def link gdscriptTripleQuotes String
|
|
92 hi def link gdscriptEscape Special
|
|
93 hi def link gdscriptNode PreProc
|
|
94 hi def link gdscriptType Type
|
|
95 hi def link gdscriptNumber Number
|
|
96 hi def link gdscriptBlockStart Special
|
|
97 hi def link gdscriptTodo Todo
|
|
98
|
|
99
|
|
100 let b:current_syntax = "gdscript"
|
|
101
|
|
102 let &cpo = s:keepcpo
|
|
103 unlet s:keepcpo
|