Skip to content

Instantly share code, notes, and snippets.

@tooolbox
Last active June 23, 2021 00:43
Show Gist options
  • Save tooolbox/9ec6ad008d9443f0ac15dd8cfb27adaa to your computer and use it in GitHub Desktop.
Save tooolbox/9ec6ad008d9443f0ac15dd8cfb27adaa to your computer and use it in GitHub Desktop.
Teal plugin for SublimeLinter
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