Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress diagnostics on the current line #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 24 additions & 5 deletions autoload/lsc/highlights.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,34 @@ function! lsc#highlights#update() abort
if s:CurrentWindowIsFresh() | return | endif
call lsc#highlights#clear()
if &diff | return | endif
for line in values(lsc#diagnostics#forFile(lsc#file#fullPath()))
for diagnostic in line
let match = matchaddpos(diagnostic.group, diagnostic.ranges, -1)
call add(w:lsc_diagnostic_matches, match)
endfor
let l:is_insert = mode() == 'i'
if exists('w:lsc_diagnostic_deferred')
unlet w:lsc_diagnostic_deferred
endif
for [line, diagnostics] in items(lsc#diagnostics#forFile(lsc#file#fullPath()))
if l:is_insert && l:line == line('.')
let w:lsc_diagnostic_deferred = l:diagnostics
call lsc#util#once('CursorHold,CursorMoved',
\ function('<SID>UpdateDeferred'))
else
for diagnostic in l:diagnostics
let match = matchaddpos(diagnostic.group, diagnostic.ranges, -1)
call add(w:lsc_diagnostic_matches, match)
endfor
endif
endfor
call s:MarkCurrentWindowFresh()
endfunction

function! s:UpdateDeferred() abort
if !exists('w:lsc_diagnostic_deferred') | return | endif
for l:diagnostic in w:lsc_diagnostic_deferred
let match = matchaddpos(diagnostic.group, diagnostic.ranges, -1)
call add(w:lsc_diagnostic_matches, match)
endfor
unlet w:lsc_diagnostic_deferred
endfunction

" Remove all highlighted matches in the current window.
function! lsc#highlights#clear() abort
if exists('w:lsc_diagnostic_matches')
Expand Down