29996
|
1 " Vim syntax file for Godot resource (scenes)
|
|
2 " Language: gdresource
|
|
3 " Maintainer: Maxim Kim <habamax@gmail.com>
|
|
4 " Filenames: *.tscn, *.tres
|
30085
|
5 " Website: https://github.com/habamax/vim-gdscript
|
29996
|
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 syn match gdResourceNumber "\<0x\%(_\=\x\)\+\>"
|
|
15 syn match gdResourceNumber "\<0b\%(_\=[01]\)\+\>"
|
|
16 syn match gdResourceNumber "\<\d\%(_\=\d\)*\>"
|
|
17 syn match gdResourceNumber "\<\d\%(_\=\d\)*\%(e[+-]\=\d\%(_\=\d\)*\)\=\>"
|
|
18 syn match gdResourceNumber "\<\d\%(_\=\d\)*\.\%(e[+-]\=\d\%(_\=\d\)*\)\=\%(\W\|$\)\@="
|
|
19 syn match gdResourceNumber "\%(^\|\W\)\@1<=\%(\d\%(_\=\d\)*\)\=\.\d\%(_\=\d\)*\%(e[+-]\=\d\%(_\=\d\)*\)\=\>"
|
|
20
|
|
21 syn keyword gdResourceKeyword true false
|
|
22
|
|
23 syn region gdResourceString
|
|
24 \ start=+[uU]\="+ end='"' skip='\\\\\|\\"'
|
|
25 \ contains=@Spell keepend
|
|
26
|
|
27 " Section
|
|
28 syn region gdResourceSection matchgroup=gdResourceSectionDelimiter
|
|
29 \ start='^\[' end=']\s*$'
|
|
30 \ oneline keepend
|
|
31 \ contains=gdResourceSectionName,gdResourceSectionAttribute
|
|
32
|
|
33 syn match gdResourceSectionName '\[\@<=\S\+' contained skipwhite
|
|
34 syn match gdResourceSectionAttribute '\S\+\s*=\s*\S\+'
|
|
35 \ skipwhite keepend contained
|
|
36 \ contains=gdResourceSectionAttributeName,gdResourceSectionAttributeValue
|
|
37 syn match gdResourceSectionAttributeName '\S\+\ze\(\s*=\)' skipwhite contained
|
|
38 syn match gdResourceSectionAttributeValue '\(=\s*\)\zs\S\+\ze' skipwhite
|
|
39 \ contained
|
|
40 \ contains=gdResourceString,gdResourceNumber,gdResourceKeyword
|
|
41
|
|
42
|
|
43 " Section body
|
|
44 syn match gdResourceAttribute '^\s*\S\+\s*=.*$'
|
|
45 \ skipwhite keepend
|
|
46 \ contains=gdResourceAttributeName,gdResourceAttributeValue
|
|
47
|
|
48 syn match gdResourceAttributeName '\S\+\ze\(\s*=\)' skipwhite contained
|
|
49 syn match gdResourceAttributeValue '\(=\s*\)\zs.*$' skipwhite
|
|
50 \ contained
|
|
51 \ contains=gdResourceString,gdResourceNumber,gdResourceKeyword
|
|
52
|
|
53
|
|
54 hi def link gdResourceNumber Constant
|
|
55 hi def link gdResourceKeyword Constant
|
|
56 hi def link gdResourceSectionName Statement
|
|
57 hi def link gdResourceSectionDelimiter Delimiter
|
|
58 hi def link gdResourceSectionAttributeName Type
|
|
59 hi def link gdResourceAttributeName Identifier
|
|
60 hi def link gdResourceString String
|
|
61
|
|
62 let b:current_syntax = "gdresource"
|
|
63
|
|
64 let &cpo = s:keepcpo
|
|
65 unlet s:keepcpo
|