Skip to content
Merged
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
34 changes: 33 additions & 1 deletion linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""This module exports the Ruby plugin class."""

from SublimeLinter.lint import RubyLinter
import re


class Ruby(RubyLinter):
Expand Down Expand Up @@ -39,4 +40,35 @@ def split_match(self, match):
if match.group('file') != '-':
match = None

return super().split_match(match)
match, line, col, error, warning, message, _ = super().split_match(match)
near = self.search_token(message)

return match, line, col, error, warning, message, near

def search_token(self, message):
"""Search text token to be highlighted."""

# First search for variable name enclosed in quotes
m = re.search("(?<=`).*(?=')", message)

# Then search for variable name following a dash
if m is None:
m = re.search('(?<= - )\S+', message)

# Then search for mismatched indentation
if m is None:
m = re.search("(?<=mismatched indentations at ')end", message)

# Then search for equal operator in conditional
if m is None:
m = re.search('(?<=found )=(?= in conditional)', message)

# Then search for use of operator in void context
if m is None:
m = re.search('\S+(?= in void context)', message)

# Then search for END in method
if m is None:
m = re.search('END(?= in method)', message)

return m.group(0) if m else None