mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
Fix #4399 - Manage virtual-text state better
This commit is contained in:
@@ -5,10 +5,14 @@ scriptencoding utf-8
|
|||||||
|
|
||||||
" Controls the milliseconds delay before showing a message.
|
" Controls the milliseconds delay before showing a message.
|
||||||
let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10)
|
let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10)
|
||||||
let s:cursor_timer = -1
|
let s:cursor_timer = get(s:, 'cursor_timer', -1)
|
||||||
let s:last_pos = [0, 0, 0]
|
let s:last_pos = get(s:, 'last_pos', [0, 0, 0])
|
||||||
|
let s:hl_list = get(s:, 'hl_list', [])
|
||||||
|
|
||||||
|
if !has_key(s:, 'has_virt_text')
|
||||||
let s:has_virt_text = 0
|
let s:has_virt_text = 0
|
||||||
let s:emulate_virt = 0
|
let s:emulate_virt = 0
|
||||||
|
let s:last_virt = -1
|
||||||
|
|
||||||
if has('nvim-0.3.2')
|
if has('nvim-0.3.2')
|
||||||
let s:ns_id = nvim_create_namespace('ale')
|
let s:ns_id = nvim_create_namespace('ale')
|
||||||
@@ -16,11 +20,10 @@ if has('nvim-0.3.2')
|
|||||||
elseif has('textprop') && has('popupwin')
|
elseif has('textprop') && has('popupwin')
|
||||||
let s:has_virt_text = 1
|
let s:has_virt_text = 1
|
||||||
let s:emulate_virt = !has('patch-9.0.0297')
|
let s:emulate_virt = !has('patch-9.0.0297')
|
||||||
let s:hl_list = []
|
|
||||||
|
|
||||||
if s:emulate_virt
|
if s:emulate_virt
|
||||||
call prop_type_add('ale', {})
|
call prop_type_add('ale', {})
|
||||||
let s:last_virt = -1
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -71,13 +74,17 @@ function! ale#virtualtext#ShowMessage(message, hl_group, buf, line) abort
|
|||||||
\ 'zindex': 2
|
\ 'zindex': 2
|
||||||
\})
|
\})
|
||||||
else
|
else
|
||||||
let type = prop_type_get(a:hl_group)
|
let l:type = prop_type_get(a:hl_group)
|
||||||
|
|
||||||
if type == {}
|
if l:type == {}
|
||||||
call add(s:hl_list, a:hl_group)
|
|
||||||
call prop_type_add(a:hl_group, {'highlight': a:hl_group})
|
call prop_type_add(a:hl_group, {'highlight': a:hl_group})
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Add highlight groups to the list so we can clear them later.
|
||||||
|
if index(s:hl_list, a:hl_group) == -1
|
||||||
|
call add(s:hl_list, a:hl_group)
|
||||||
|
endif
|
||||||
|
|
||||||
call prop_add(a:line, 0, {
|
call prop_add(a:line, 0, {
|
||||||
\ 'type': a:hl_group,
|
\ 'type': a:hl_group,
|
||||||
\ 'text': ' ' . l:msg,
|
\ 'text': ' ' . l:msg,
|
||||||
@@ -93,22 +100,24 @@ function! s:StopCursorTimer() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#virtualtext#GetHlGroup(type, style) abort
|
function! ale#virtualtext#GetHlGroup(type, sub_type) abort
|
||||||
if a:type is# 'E'
|
if a:type is# 'E'
|
||||||
if a:style is# 'style'
|
if a:sub_type is# 'style'
|
||||||
return 'ALEVirtualTextStyleError'
|
return 'ALEVirtualTextStyleError'
|
||||||
else
|
endif
|
||||||
|
|
||||||
return 'ALEVirtualTextError'
|
return 'ALEVirtualTextError'
|
||||||
endif
|
endif
|
||||||
elseif a:type is# 'W'
|
|
||||||
if a:style is# 'style'
|
if a:type is# 'W'
|
||||||
|
if a:sub_type is# 'style'
|
||||||
return 'ALEVirtualTextStyleWarning'
|
return 'ALEVirtualTextStyleWarning'
|
||||||
else
|
endif
|
||||||
|
|
||||||
return 'ALEVirtualTextWarning'
|
return 'ALEVirtualTextWarning'
|
||||||
endif
|
endif
|
||||||
else
|
|
||||||
return 'ALEVirtualTextInfo'
|
return 'ALEVirtualTextInfo'
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#virtualtext#ShowCursorWarning(...) abort
|
function! ale#virtualtext#ShowCursorWarning(...) abort
|
||||||
@@ -181,7 +190,7 @@ function! ale#virtualtext#SetTexts(buf, loclist) abort
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let hl = ale#virtualtext#GetHlGroup(l['type'], get(l, 'sub_type', ''))
|
let l:hl = ale#virtualtext#GetHlGroup(l['type'], get(l, 'sub_type', ''))
|
||||||
call ale#virtualtext#ShowMessage(l['text'], hl, a:buf, l['lnum'])
|
call ale#virtualtext#ShowMessage(l['text'], l:hl, a:buf, l['lnum'])
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user