Skip to content

Instantly share code, notes, and snippets.

@yongkangchen
Created May 19, 2014 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yongkangchen/be50bd333966840c3975 to your computer and use it in GitHub Desktop.
Save yongkangchen/be50bd333966840c3975 to your computer and use it in GitHub Desktop.
lua syntax check when save lua file in sublime
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