Last active
June 23, 2021 00:43
-
-
Save tooolbox/9ec6ad008d9443f0ac15dd8cfb27adaa to your computer and use it in GitHub Desktop.
Teal plugin for SublimeLinter
This file contains hidden or 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
from SublimeLinter.lint import Linter, LintMatch | |
import re | |
class TealLinter(Linter): | |
cmd = 'tl check ${file} ${args}' | |
defaults = { | |
'selector': 'source.lua, source.teal' | |
} | |
on_stderr = None | |
tempfile_suffix = '-' | |
mdr = r'^\d+ (errors?|warnings?):$' | |
msgr = r'^(?P<filename>.+?):(?P<line>\d+):(?P<col>\d+):\s+(?P<message>.+)$' | |
def find_errors(self, output): | |
mode = 'warnings' | |
lines = output.rstrip().split('\n') | |
for ln in lines: | |
m = re.match(self.mdr, ln) | |
if m: | |
mode = m.group(1) | |
msg = re.match(self.msgr, ln) | |
if msg: | |
d = msg.groupdict() | |
yield LintMatch( | |
# match=d['message'], | |
filename=d['filename'], | |
line=int(d['line'])-1, | |
col=int(d['col'])-1, | |
error_type='error' if mode.startsWith('error') else 'warning', | |
# code='', | |
message=d['message'], | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment