-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinter.py
55 lines (48 loc) · 1.58 KB
/
linter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
#
# Copyright (c) 2014 CorvisaCloud, LLC
#
# License: MIT
#
"""This module exports the LuaSummit plugin class."""
from SublimeLinter.lint import Linter, util
class SummitLinter(Linter):
"""Provides an interface to luacheck for the SummitEditor syntax."""
syntax = 'summit'
tempfile_suffix = 'lua'
defaults = {
'--ignore:,': 'channel',
'--only:,': '',
'--limit=': None,
'--globals: ': '',
}
comment_re = r'\s*-[-*]'
inline_settings = ('ignore', 'limit', 'only', 'globals')
cmd = 'luacheck @ *'
regex = r'^(?P<filename>[^:]+):(?P<line>\d+):(?P<col>\d+): (?P<message>.*)$'
def build_args(self, settings):
"""Return args, transforming --ignore, --only, and --globals args into a format luacheck understands."""
args = super().build_args(settings)
try:
index = args.index('--ignore')
# Split the comma-separated arg after --ignore into separate elements
vars = args[index + 1].split(',')
args[index + 1:index + 2] = vars
except ValueError:
pass
try:
index = args.index('--only')
vars = args[index + 1].split(',')
args[index + 1:index + 2] = vars
except ValueError:
pass
try:
index = args.index('--globals')
vars = args[index + 1].split(',')
args[index + 1:index + 2] = vars
except ValueError:
pass
return args