Skip to content

Commit 417a703

Browse files
author
TJ Kells
committed
WIP
1 parent 348906c commit 417a703

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

build.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""
23
The MIT License (MIT)
34
@@ -24,10 +25,11 @@
2425

2526
import os
2627
import platform
28+
import re
2729
import sublime
2830
import sublime_plugin
2931

30-
from subprocess import Popen
32+
from subprocess import Popen, PIPE, STDOUT
3133

3234
SUMMIT_PLUGIN_PATH = os.path.split(os.path.abspath(__file__))[0]
3335
SUMMIT_SETTINGS = sublime.load_settings('SummitEditor.sublime-settings')
@@ -85,8 +87,28 @@ def simulate_with_args(self, sim_args):
8587

8688
class SummitAutoBuildOnSave(sublime_plugin.EventListener):
8789
def on_post_save(self, view):
90+
window = sublime.active_window()
8891
is_summit_file = view.scope_name(0).startswith('source.lua.summit')
8992
auto_build = SUMMIT_SETTINGS.get('summit_simulate_on_save')
93+
auto_lint = SUMMIT_SETTINGS.get('summit_lint_on_save')
9094

9195
if is_summit_file and auto_build:
92-
sublime.active_window().run_command('build')
96+
window.run_command('build')
97+
98+
if is_summit_file and auto_lint:
99+
output_panel = window.create_output_panel("mono")
100+
window.run_command("show_panel", {"panel": "output.mono"})
101+
102+
cmd = [
103+
'luacheck',
104+
view.file_name(),
105+
'--ignore',
106+
'channel',
107+
'util',
108+
'_S'
109+
]
110+
proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=1)
111+
output = '\n'.join([l.decode(encoding='UTF-8') for l in iter(proc.stdout.readline, b'')])
112+
113+
ansi_escape = re.compile(r'\x1b[^m]*m')
114+
output_panel.run_command("append", {"characters": ansi_escape.sub('', output)})

0 commit comments

Comments
 (0)