Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This linter plugin for [SublimeLinter](https://github.com/SublimeLinter/SublimeL
It will be used with all files.

## Installation
SublimeLinter must be installed in order to use this plugin.
SublimeLinter must be installed in order to use this plugin.

Please use [Package Control](https://packagecontrol.io) to install the linter plugin.

Expand All @@ -29,7 +29,7 @@ For example:
```json
"linters": {
"annotations": {
"warnings": "[FOO], BAR",
"warnings": ["FOO", "BAR"],
"errors": ["WHAT?", "OMG!"]
}
}
Expand Down
23 changes: 15 additions & 8 deletions linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,26 @@ class Annotations(Linter):

cmd = None
line_col_base = (0, 0)
regex = re.compile(r'^(?P<line>\d+):(?P<col>\d+):'
r' (warning \((?P<warning>.+?)\)|error \((?P<error>.+?)\)):'
r' (?P<message>.*)')
regex = (
r'^(?P<line>\d+):(?P<col>\d+):'
r' (?P<error_type>.+?) \((?P<code>.+)\):'
r' (?P<message>.*)'
)

# We use this to do the matching
mark_regex_template = r'(?:(?P<warning>{warnings})|(?P<error>{errors})):?\s*(?P<message>.*)'
mark_regex_template = r'(?:(?P<info>{infos})|(?P<warning>{warnings})|(?P<error>{errors})):?\s*(?P<message>.*)'

# Words to look for
defaults = {
'selector': '', # select all views
'errors': ['FIXME'],
'warnings': ['NOTE', 'README', 'TODO', '@todo', 'XXX', 'WIP'],
'errors': ['FIXME', 'ERROR'],
'warnings': ['TODO', '@todo', 'XXX', 'WIP', 'WARNING'],
'infos': ['NOTE', 'README', 'INFO'],
}

def run(self, cmd, code):
options = {}
for option in ('errors', 'warnings'):
for option in ('errors', 'warnings', 'infos'):
words = self.settings.get(option)
options[option] = '|'.join(_escape_words(words))

Expand All @@ -79,7 +82,11 @@ def run(self, cmd, code):
error_type = ERROR
else:
word = match.group('warning')
error_type = WARNING
if word:
error_type = WARNING
else:
word = match.group('info')
error_type = 'info'

output.append('{row}:{col}: {error_type} ({word}): {message}'
.format(**locals()))
Expand Down