Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / share / vim / vim58 / syntax / lua.vim
blobd6ee9d5549715ad19c8b14fc506eaab47d5e46cb
1 " Vim syntax file
2 " Language:     Lua
3 " Author:       Carlos Augusto Teixeira Mendes <cmendes@inf.puc-rio.br>
4 " Last Change:  09 october 1998
6 " Still has some syncing problems...
9 " For version 5.x: Clear all syntax items
10 " For version 6.x: Quit when a syntax file was already loaded
11 if version < 600
12   syntax clear
13 elseif exists("b:current_syntax")
14   finish
15 endif
17 syn case match
19 "Comments
20 syn keyword luaTodo             contained TODO FIXME XXX
21 syn match   luaComment          "--.*$" contains=luaTodo
23 "catch errors caused by wrong parenthesis and wrong curly brackets or
24 "keywords placed outside their respective blocks
26 syn region luaParen             transparent start='(' end=')' contains=ALLBUT,luaError,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd,luaCondStart,luaBlock,luaRepeatBlock,luaStatement
27 syn match   luaError            ")"
28 syn match   luaError            "}"
29 syn match   luaError            "\<\(end\|else\|elseif\|then\|until\)\>"
32 "Function declaration
33 syn region  luaFunctionBlock    transparent matchgroup=luaFunction start="\<function\>" end="\<end\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
35 "if then else elseif end
36 syn keyword luaCond             contained else
38 syn region  luaCondEnd          contained transparent matchgroup=luaCond start="\<then\>" end="\<end\>" contains=ALLBUT,luaTodo,luaSpecial
40 syn region  luaCondElseif       contained transparent matchgroup=luaCond start="\<elseif\>" end="\<then\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
42 syn region  luaCondStart        transparent matchgroup=luaCond start="\<if\>" end="\<then\>"me=e-4 contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd nextgroup=luaCondEnd skipwhite skipempty
46 " do end block
47 syn region  luaBlock            transparent matchgroup=luaStatement start="\<do\>" end="\<end\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
49 "repeat until and while do blocks
50 syn region  luaRepeatBlock      transparent matchgroup=luaRepeat start="\<repeat\>" end="\<until\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
52 syn region  luaRepeatBlock      transparent matchgroup=luaRepeat start="\<while\>" end="\<do\>"me=e-2 contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd nextgroup=luaBlock skipwhite skipempty
54 "other keywords
55 syn keyword luaStatement        return local
56 syn keyword luaOperator         and or not
57 syn keyword luaConstant         nil
59 "Pre processor
60 syn match   luaPreProc          "^\s*$\(debug\|nodebug\|if\|ifnot\|end\|else\|endinput\)\>"
62 "Strings
63 syn match   luaSpecial          contained "\\[ntr]"
64 syn region  luaString           start=+'+  end=+'+ skip=+\\\\\|\\'+ contains=luaSpecial
65 syn region  luaString           start=+"+  end=+"+ skip=+\\\\\|\\"+ contains=luaSpecial
66 syn region  luaString           start=+\[\[+ end=+\]\]+
68 "integer number
69 syn match luaNumber             "\<[0-9]\+\>"
70 "floating point number, with dot, optional exponent
71 syn match luaFloat              "\<[0-9]\+\.[0-9]*\(e[-+]\=[0-9]\+\)\=\>"
72 "floating point number, starting with a dot, optional exponent
73 syn match luaFloat              "\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\>"
74 "floating point number, without dot, with exponent
75 syn match luaFloat              "\<[0-9]\+e[-+]\=[0-9]\+\>"
77 "tables
78 syn region  luaTableBlock       transparent matchgroup=luaTable start="{" end="}" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd,luaCondStart,luaBlock,luaRepeatBlock,luaStatement
80 "internal functions
81 syn keyword luaInternalFunc  assert call collectgarbage dofile copytagmethods
82 syn keyword luaInternalFunc  dostring error foreach foreachvar getglobal
83 syn keyword luaInternalFunc  newtag next nextvar print rawgetglobal
84 syn keyword luaInternalFunc  rawgettable rawsetglobal rawsettable seterrormethod
85 syn keyword luaInternalFunc  setglobal settagmethod gettagmethod settag tonumber
86 syn keyword luaInternalFunc  tostring tag type
88 "standard libraries
89 syn keyword luaStdLibFunc    setlocale execute remove rename tmpname
90 syn keyword luaStdLibFunc    getenv date clock exit debug print_stack
91 syn keyword luaStdLibFunc    readfrom writeto appendto read write
92 syn keyword luaStdLibFunc    abs sin cos tan asin
93 syn keyword luaStdLibFunc    acos atan atan2 ceil floor
94 syn keyword luaStdLibFunc    mod frexp ldexp sqrt min max log
95 syn keyword luaStdLibFunc    log10 exp deg rad random
96 syn keyword luaStdLibFunc    randomseed strlen strsub strlower strupper
97 syn keyword luaStdLibFunc    strchar strrep ascii strbyte format
98 syn keyword luaStdLibFunc    strfind gsub
101 "syncing method
102 syn sync minlines=100
104 " Define the default highlighting.
105 " For version 5.7 and earlier: only when not done already
106 " For version 5.8 and later: only when an item doesn't have highlighting yet
107 if version >= 508 || !exists("did_lua_syntax_inits")
108   if version < 508
109     let did_lua_syntax_inits = 1
110     command -nargs=+ HiLink hi link <args>
111   else
112     command -nargs=+ HiLink hi def link <args>
113   endif
115   HiLink luaStatement           Statement
116   HiLink luaRepeat              Repeat
117   HiLink luaString              String
118   HiLink luaNumber              Number
119   HiLink luaFloat               Float
120   HiLink luaOperator            Operator
121   HiLink luaConstant            Constant
122   HiLink luaCond                Conditional
123   HiLink luaFunction            Function
124   HiLink luaComment             Comment
125   HiLink luaTodo                Todo
126   HiLink luaTable               Structure
127   HiLink luaError               Error
128   HiLink luaSpecial             SpecialChar
129   HiLink luaPreProc             PreProc
130   HiLink luaInternalFunc        Identifier
131   HiLink luaStdLibFunc          Identifier
133   delcommand HiLink
134 endif
136 let b:current_syntax = "lua"
138 " vim: ts=8