'*******************************************************************************
' EverEdit Syntax File
' Language: lua
' Author: yugi
' Maintainer: www.gccyugi.com
' History:
'   2012/06/28 First Version
'   2013/03/22 Update some details
'	2016/09/9  Imporved sr_multi_string match
'*******************************************************************************

Include(".\const.mac")

Set lua=CreateParser()

'comment
Set r_block_comment=lua.CreateRegion(COLOR_COMMENT1, "+--[[+", "+]]+", True)
Set r_line_comment=lua.CreateRegion(COLOR_COMMENT1, "+--+", "$", True)
lua.AddRegion(r_block_comment)
lua.AddRegion(r_line_comment)

'string
Set sr_single_string=lua.CreateStringRegion(COLOR_STRING1, "'", "\", False)
Set sr_double_string=lua.CreateStringRegion(COLOR_STRING2, """", "\", False)
Set sr_multi_string=lua.CreateRegion(COLOR_STRING2, "\[={0,5}\[", "\]={0,5}\]", True)
lua.AddRegion(sr_single_string)
lua.AddRegion(sr_double_string)
lua.AddRegion(sr_multi_string)

'function def
lua.AddItem(lua.CreateItem(COLOR_FUNCTION, "\b(function)\s+([a-zA-Z_.:]+[.:])?([a-zA-Z_]\w*)\s*(?=(\()([^)]*)(\)))", False))

'number
lua.AddItem(lua.CreateItem(COLOR_NUMBER, "\b\d+\b", False))

'reserved keywords
lua.AddWord(lua.CreateWord(COLOR_WORD1, "and break do else elseif end false for function if in local nil not or repeat return then true until while", True))

'builtin core functions
lua.AddItem(lua.CreateWord(COLOR_WORD2, "abs acos asin atan atan2 ceil cos deg exp floor format frexp gsub ldexp log log10 max min mod rad random randomseed sin sqrt strbyte strchar strfind strlen strlower strrep strsub strupper tan", True))

lua.AddItem(lua.CreateWord(COLOR_WORD2, "string table math coroutine io", True))

'builtin extra functions
lua.AddItem(lua.CreateWord(COLOR_WORD2, "openfile closefile readfrom writeto appendto remove rename flush seek tmpfile tmpname read write clock date difftime execute exit getenv setlocale time", True))

'builtin symbols
lua.AddItem(lua.CreateWord(COLOR_WORD3, "_VERSION assert collectgarbage dofile error gcinfo loadfile loadstring print tonumber tostring type unpack _ALERT _ERRORMESSAGE _INPUT _PROMPT _OUTPUT _STDERR _STDIN _STDOUT call dostring foreach foreachi getn globals newtype rawget rawset require sort tinsert tremove _G getfenv getmetatable ipairs loadlib next pairs pcall rawegal rawget rawset require setfenv setmetatable xpcall", True))

'extra
'Call lua.FoldText("\s*\b(function|local\s+function|if|do|while|repeat|for)\b|\{", True)
Call lua.FoldText("\s*\b(function|local\s+function|if|while|repeat|for)\b|^\s*\bdo\b|\{", True)
Call lua.UnfoldText("\bend\b|\}", True)

Call lua.IndentText("^\s*(function|if|else|do|while|elseif|repeat|for)\b", True)
Call lua.UnindentText("\b(end|else)$", True)

Call lua.SetPairs("[](){}""""''")

Call lua.CommentLine("--")
Call lua.CommentBlock("--[[", "]]")

lua.AddSnippet "lua.snippet"
lua.AddCallTip "lua.ecp", True, "."