home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / mac / vim55rt.sit / runtime / syntax / lua.vim < prev    next >
Encoding:
Text File  |  1999-09-25  |  4.9 KB  |  123 lines  |  [TEXT/VIM!]

  1. " Vim syntax file
  2. " Language:    Lua
  3. " Author:    Carlos Augusto Teixeira Mendes <cmendes@inf.puc-rio.br>
  4. " Last change:    09 october 1998
  5. "
  6. " Still has some syncing problems...
  7.  
  8.  
  9. " Remove any old syntax stuff hanging around
  10. syn clear
  11. syn case match
  12.  
  13. "Comments
  14. syn keyword luaTodo             contained TODO FIXME XXX
  15. syn match   luaComment          "--.*$" contains=luaTodo
  16.  
  17. "catch errors caused by wrong parenthesis and wrong curly brackets or
  18. "keywords placed outside their respective blocks
  19.  
  20. syn region luaParen        transparent start='(' end=')' contains=ALLBUT,luaError,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd,luaCondStart,luaBlock,luaRepeatBlock,luaStatement
  21. syn match   luaError        ")"
  22. syn match   luaError        "}"
  23. syn match   luaError        "\<\(end\|else\|elseif\|then\|until\)\>"
  24.  
  25.  
  26. "Function declaration
  27. syn region  luaFunctionBlock    transparent matchgroup=luaFunction start="\<function\>" end="\<end\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
  28.  
  29. "if then else elseif end
  30. syn keyword luaCond        contained else
  31.  
  32. syn region  luaCondEnd        contained transparent matchgroup=luaCond start="\<then\>" end="\<end\>" contains=ALLBUT,luaTodo,luaSpecial
  33.  
  34. syn region  luaCondElseif    contained transparent matchgroup=luaCond start="\<elseif\>" end="\<then\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
  35.  
  36. syn region  luaCondStart    transparent matchgroup=luaCond start="\<if\>" end="\<then\>"me=e-4 contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd nextgroup=luaCondEnd skipwhite skipempty
  37.  
  38.  
  39.  
  40. " do end block
  41. syn region  luaBlock        transparent matchgroup=luaStatement start="\<do\>" end="\<end\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
  42.  
  43. "repeat until and while do blocks
  44. syn region  luaRepeatBlock    transparent matchgroup=luaRepeat start="\<repeat\>" end="\<until\>" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd
  45.  
  46. syn region  luaRepeatBlock    transparent matchgroup=luaRepeat start="\<while\>" end="\<do\>"me=e-2 contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd nextgroup=luaBlock skipwhite skipempty
  47.  
  48. "other keywords
  49. syn keyword luaStatement    return local
  50. syn keyword luaOperator        and or not
  51. syn keyword luaConstant        nil
  52.  
  53. "Pre processor
  54. syn match   luaPreProc          "^\s*$\(debug\|nodebug\|if\|ifnot\|end\|else\|endinput\)\>"
  55.  
  56. "Strings
  57. syn match   luaSpecial        contained "\\[ntr]"
  58. syn region  luaString        start=+'+  end=+'+ skip=+\\\\\|\\'+ contains=luaSpecial
  59. syn region  luaString        start=+"+  end=+"+ skip=+\\\\\|\\"+ contains=luaSpecial
  60. syn region  luaString        start=+\[\[+ end=+\]\]+
  61.  
  62. "integer number
  63. syn match luaNumber        "\<[0-9]\+\>"
  64. "floating point number, with dot, optional exponent
  65. syn match luaFloat        "\<[0-9]\+\.[0-9]*\(e[-+]\=[0-9]\+\)\=\>"
  66. "floating point number, starting with a dot, optional exponent
  67. syn match luaFloat        "\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\>"
  68. "floating point number, without dot, with exponent
  69. syn match luaFloat        "\<[0-9]\+e[-+]\=[0-9]\+\>"
  70.  
  71. "tables
  72. syn region  luaTableBlock       transparent matchgroup=luaTable start="{" end="}" contains=ALLBUT,luaTodo,luaSpecial,luaCond,luaCondElseif,luaCondEnd,luaCondStart,luaBlock,luaRepeatBlock,luaStatement
  73.  
  74. "internal functions
  75. syn keyword luaInternalFunc  assert call collectgarbage dofile copytagmethods
  76. syn keyword luaInternalFunc  dostring error foreach foreachvar getglobal
  77. syn keyword luaInternalFunc  newtag next nextvar print rawgetglobal
  78. syn keyword luaInternalFunc  rawgettable rawsetglobal rawsettable seterrormethod
  79. syn keyword luaInternalFunc  setglobal settagmethod gettagmethod settag tonumber
  80. syn keyword luaInternalFunc  tostring tag type
  81.  
  82. "standard libraries
  83. syn keyword luaStdLibFunc    setlocale execute remove rename tmpname
  84. syn keyword luaStdLibFunc    getenv date clock exit debug print_stack
  85. syn keyword luaStdLibFunc    readfrom writeto appendto read write
  86. syn keyword luaStdLibFunc    abs sin cos tan asin
  87. syn keyword luaStdLibFunc    acos atan atan2 ceil floor
  88. syn keyword luaStdLibFunc    mod frexp ldexp sqrt min max log
  89. syn keyword luaStdLibFunc    log10 exp deg rad random
  90. syn keyword luaStdLibFunc    randomseed strlen strsub strlower strupper
  91. syn keyword luaStdLibFunc    strchar strrep ascii strbyte format
  92. syn keyword luaStdLibFunc    strfind gsub
  93.  
  94.  
  95. "syncing method
  96. syn sync minlines=100
  97.  
  98. if !exists("did_lua_syntax_inits")
  99.   let did_lua_syntax_inits = 1
  100.   " The default methods for highlighting.  Can be overridden later
  101.   hi link luaStatement        Statement
  102.   hi link luaRepeat        Repeat
  103.   hi link luaString        String
  104.   hi link luaNumber        Number
  105.   hi link luaFloat        Float
  106.   hi link luaOperator        Operator
  107.   hi link luaConstant        Constant
  108.   hi link luaCond            Conditional
  109.   hi link luaFunction        Function
  110.   hi link luaComment        Comment
  111.   hi link luaTodo        Todo
  112.   hi link luaTable        Structure
  113.   hi link luaError        Error
  114.   hi link luaSpecial        SpecialChar
  115.   hi link luaPreProc        PreProc
  116.   hi link luaInternalFunc    Identifier
  117.   hi link luaStdLibFunc        Identifier
  118. endif
  119.  
  120. let b:current_syntax = "lua"
  121.  
  122. " vim: ts=8
  123.