Skip to content
Open
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
3 changes: 3 additions & 0 deletions GoSublime.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gosubl/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 15 additions & 13 deletions gslint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down