diff --git a/GoSublime.sublime-settings b/GoSublime.sublime-settings index 1238368a..4d2df73d 100644 --- a/GoSublime.sublime-settings +++ b/GoSublime.sublime-settings @@ -49,6 +49,9 @@ // Whether or not gslint is enabled "gslint_enabled": true, + // Draw an outline around lines with a lint error + "gslint_outline": false, + // filter the kinds of lint checks that are done. supported kinds: // // gs.syntax - parser/syntax errors - it makes no sense to filter this as it will simply diff --git a/gosubl/gs.py b/gosubl/gs.py index f34bba86..a17dbdca 100644 --- a/gosubl/gs.py +++ b/gosubl/gs.py @@ -70,6 +70,7 @@ "comp_lint_enabled": False, "comp_lint_commands": [], "gslint_timeout": 0, + "gslint_outline": False, "calltips": True, "autocomplete_snippets": False, "autocomplete_tests": False, diff --git a/gslint.py b/gslint.py index 578c9785..945621e8 100644 --- a/gslint.py +++ b/gslint.py @@ -88,28 +88,30 @@ def highlight(fr): fr.state = 0 cleanup(fr.view) - regions = [] - regions0 = [] - domain0 = DOMAIN+'-zero' + line_regions = [] + col_regions = [] for r in fr.reports.values(): line = fr.view.line(fr.view.text_point(r.row, 0)) pos = line.begin() + r.col if pos >= line.end(): pos = line.end() - if pos == line.begin(): - regions0.append(sublime.Region(pos, pos)) - else: - regions.append(sublime.Region(pos, pos)) - if regions: - fr.view.add_regions(DOMAIN, regions, 'comment', 'dot', sublime.DRAW_EMPTY_AS_OVERWRITE) + line_regions.append(sublime.Region(line.begin(), line.end())) + if pos != line.begin(): + col_regions.append(sublime.Region(pos, pos)) + + if line_regions: + if gs.setting('gslint_outline'): + fr.view.add_regions(DOMAIN, line_regions, 'comment', 'dot', sublime.DRAW_OUTLINED) + else: + fr.view.add_regions(DOMAIN, line_regions, 'comment', 'dot', sublime.HIDDEN) else: fr.view.erase_regions(DOMAIN) - if regions0: - fr.view.add_regions(domain0, regions0, 'comment', 'dot', sublime.HIDDEN) + if col_regions: + fr.view.add_regions(DOMAIN + '-col', col_regions, 'comment', '', sublime.DRAW_EMPTY_AS_OVERWRITE) else: - fr.view.erase_regions(domain0) + fr.view.erase_regions(DOMAIN + '-col') msg = '' reps = fr.reports.copy() @@ -128,7 +130,7 @@ def highlight(fr): def cleanup(view): view.set_status(DOMAIN, '') view.erase_regions(DOMAIN) - view.erase_regions(DOMAIN+'-zero') + view.erase_regions(DOMAIN+'-col') def watch(): global file_refs