Created
May 19, 2014 13:41
-
-
Save yongkangchen/be50bd333966840c3975 to your computer and use it in GitHub Desktop.
lua syntax check when save lua file in sublime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
import os | |
import re | |
regex = re.compile('.*:(\d+):.*') | |
class LuaParseCheck(sublime_plugin.EventListener): | |
def on_post_save_async(self, view): | |
path = view.file_name() | |
if os.path.splitext(path)[-1] != ".lua":return | |
result = os.popen("/usr/local/bin/luac -p '"+path+"' 2>&1").read() | |
if result == "":return | |
view.run_command("goto_line", {"line": regex.search(result).group(1)} ) | |
sublime.status_message(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment