]> git.mxchange.org Git - flightgear.git/blob - utils/syntax/nasal.vim
vim syntax files for *.ac and *.nas files. See nasal.vim for how to use them.
[flightgear.git] / utils / syntax / nasal.vim
1 " Vim syntax file
2 " Language:     Nasal (FlightGear)
3 " Maintainer:   Melchior FRANZ <mfranz # aon : at>
4 " URL:          http://members.aon.at/mfranz/nasal.vim
5 " Last Change:  2005 Apr 25
6 " $Id$
7
8 " ________________________________CUSTOMIZATION______________________________
9 "
10 " :let nasal_no_fgfs=1               " turn off FlightGear extensions
11 " :hi nasalStatement ctermfg=Green   " change statement color
12 " ___________________________________________________________________________
13 " for use in ~/.vimrc drop the initial colon
14 " type ":help new-filetype" in vim for installation instructions
15
16
17 if !exists("main_syntax")
18         if version < 600
19                 syntax clear
20         elseif exists("b:current_syntax")
21                 finish
22         endif
23         let main_syntax = 'nasal'
24 endif
25
26
27 syn keyword nasalCommentTodo            TODO FIXME XXX contained
28 syn match   nasalComment                "#.*$" contains=nasalCommentTodo
29 syn region  nasalStringS                start=+'+  skip=+\\'+  end=+'+  contains=nasalSpecialS
30 syn region  nasalStringD                start=+"+  skip=+\\"+  end=+"+  contains=nasalSpecialD,nasalSpecial
31 syn match   nasalSpecialS               contained "\\'"
32 syn match   nasalSpecialD               contained "\\[\\rnt\"]"
33 syn match   nasalSpecial                contained "\\x[[:xdigit:]][[:xdigit:]]"
34
35 syn match   nasalError                  "``\="
36 syn match   nasalError                  "`\\[^`\\rnt]`"
37 syn match   nasalError                  "`[^`][^`]\+`"
38 syn match   nasalCharConstant           "`[^`\\]`"
39 syn match   nasalCharConstant           "`\\[`\\rnt]`"
40 syn match   nasalCharConstant           "`\\x[[:xdigit:]][[:xdigit:]]`"
41
42 syn match   nasalNumber                 "-\=\<\d\+\>"
43 syn match   nasalNumber                 "\.\d\+\([eE][+-]\=\d\+\)\=\>"
44 syn match   nasalNumber                 "\<\d\+\.\([eE][+-]\=\d\+\)\=\>"
45 syn match   nasalNumber                 "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=\>"
46
47 syn keyword nasalStatement              func return var
48 syn keyword nasalConditional            if elsif else
49 syn keyword nasalRepeat                 while for foreach forindex
50 syn keyword nasalBranch                 break continue
51 syn keyword nasalVar                    me arg parents
52 syn keyword nasalType                   nil
53 syn keyword nasalOperator               and or
54 syn match   nasalFoo                    "\~"
55
56 syn match   nasalFunction               display "\<contains\>"
57 syn keyword nasalFunction               size keys append pop setsize subvec delete int num streq substr
58 syn keyword nasalFunction               chr typeof compile call die sprintf caller closure find cmp
59 syn keyword nasalFunction               split rand bind sort ghosttype
60
61 " math lib
62 syn match   nasalFunction               "\<math\.\(sin\|cos\|exp\|ln\|sqrt\|atan2\)\>"
63 syn match   nasalConstant               "\<math\.\(e\|pi\)\>"
64
65 " io lib
66 syn match   nasalFunction               "\<io\.\(close\|read\|write\|seek\|tell\|open\|readln\|stat\)\>"
67 syn match   nasalVar                    "\<io\.\(SEEK_SET\|SEEK_CUR\|SEEK_END\|stdin\|stdout\|stderr\)\>"
68
69 " bits lib
70 syn match   nasalFunction               "\<bits\.\(sfld\|fld\|setfld\|buf\)\>"
71
72
73 " FlightGear specific commands
74 if !exists("nasal_no_fgfs")
75         syn keyword nasalFGFSFunction           getprop setprop print _fgcommand settimer _setlistener _cmdarg
76         syn keyword nasalFGFSFunction           _interpolate rand srand directory removelistener systime
77         syn keyword nasalFGFSFunction           geodtocart carttogeod geodinfo parsexml airportinfo
78
79         syn keyword nasalGlobalsFunction        isa fgcommand cmdarg abs interpolate setlistener defined printlog
80
81         syn keyword nasalPropsFunction          getType getName getIndex getValue setValue setIntValue
82         syn keyword nasalPropsFunction          setBoolValue setDoubleValue getParent getChild getChildren
83         syn keyword nasalPropsFunction          getAttribute setAttribute
84         syn keyword nasalPropsFunction          removeChild removeChildren getNode
85         syn keyword nasalPropsFunction          getPath getBoolValue setValues getValues
86         syn match   nasalPropsFunction          "\<props\.\(_\?globals\|Node\|nodeList\|initNode\)\>\.\="
87 endif
88
89
90 syn sync fromstart
91 syn sync maxlines=100
92
93 syn match   nasalParenError     ")"
94 syn match   nasalBrackError     "]"
95 syn match   nasalBraceError     "}"
96
97 syn region  nasalEncl transparent matchgroup=nasalParenEncl start="(" matchgroup=nasalParenEncl end=")" contains=ALLBUT,nasalParenError
98 syn region  nasalEncl transparent matchgroup=nasalBrackEncl start="\[" matchgroup=nasalBrackEncl end="\]" contains=ALLBUT,nasalBrackError
99 syn region  nasalEncl transparent matchgroup=nasalBraceEncl start="{" matchgroup=nasalBraceEncl end="}" contains=ALLBUT,nasalBraceError
100
101
102 if version >= 508 || !exists("did_nasal_syn_inits")
103         if version < 508
104                 let did_nasal_syn_inits = 1
105                 command -nargs=+ HiLink hi link <args>
106         else
107                 command -nargs=+ HiLink hi def link <args>
108         endif
109         HiLink nasalComment             Comment
110         HiLink nasalCommentTodo         Todo
111         HiLink nasalSpecial             Special
112         HiLink nasalSpecialS            Special
113         HiLink nasalSpecialD            Special
114         HiLink nasalStringS             String
115         HiLink nasalStringD             String
116         HiLink nasalNumber              Number
117         HiLink nasalConditional         Conditional
118
119         HiLink nasalVar                 Macro
120         HiLink nasalType                Type
121         HiLink nasalConstant            Constant
122         HiLink nasalCharConstant        Type
123         HiLink nasalFoo                 NonText
124
125         HiLink nasalRepeat              Repeat
126         HiLink nasalBranch              Conditional
127         HiLink nasalOperator            Operator
128         HiLink nasalStatement           Statement
129         HiLink nasalFunction            Function
130
131         HiLink nasalFGFSFunction        Function
132         HiLink nasalGlobalsFunction     Function
133         HiLink nasalPropsFunction       Function
134
135         HiLink nasalError               Error
136         HiLink nasalParenError          nasalError
137         HiLink nasalBrackError          nasalError
138         HiLink nasalBraceError          nasalError
139         delcommand HiLink
140 endif
141
142 let b:current_syntax = "nasal"
143 if main_syntax == 'nasal'
144         unlet main_syntax
145 endif
146
147 " vim: ts=8