3

I started writing a plugin for SublimeLinter and so far the linting itself is working. However, I haven't managed to get highlighting to work. Since my linter (which is actually a compiler) does not output column, I'd be happy if the failing lines would be highlighted.

The relevant portion in linter.py reads like this:

regex = (
  r'Error in script \".+?\" on line (?P<line>\d+) -- aborting creation process'
)
multiline = True
line_col_base = (1, 1)

An example error from the linter executable looks like this:

Invalid command: Naem
Error in script "/Users/testuser/Desktop/lint-test.nsi" on line 5 -- aborting creation process

I don't know how SublimeLinter can make use of the error message, so I'd be happy getting the line part right for now.

Edit: According to the comment below I tried to make use of near, but due to scarce documentation and no examples, I still haven't managed to find a solution. My updated regex pattern:

regex = (
  r'Invalid command\: (?P<near>\w+)'
  r'Error in script \"(.+?)\" on line (?P<line>\d+) -- aborting creation process'
)

Even though this would only capture misspelled commands, an answer could make it easier for me to understand how to properly capture output.

idleberg
  • 12,634
  • 7
  • 43
  • 70
  • SublimeLinter specifies "near" as parameter if plugin does not return column. Can you capture "Naem" in near group ? http://www.sublimelinter.com/en/latest/linter_attributes.html#regex Or just override the extract method: http://www.sublimelinter.com/en/latest/linter_methods.html#split-match – Dawid Gosławski Sep 01 '15 at 20:20
  • @alkuzad Thanks for the tip, that should work for invalid commands. Will give it a try on the weekend! – idleberg Sep 07 '15 at 07:06

1 Answers1

0

Here's what I ended up using:

syntax = 'nsis'
    regex = (
        r'(?P<message>[^\r?\n]+)\r?\n'
        r'(?P<error>Error) in script "[^"]+" on line (?P<line>\d+) -- aborting creation process'
    )
    multiline = True
    error_stream = util.STREAM_STDOUT
    line_col_base = (1, 1)

If I remember correctly, it was the missing line-breaks.

idleberg
  • 12,634
  • 7
  • 43
  • 70