forked from github-mirrors/ale
Implement virtual text support for vim (#3915)
This requires the textprop and popupwin feature (vim 8.2). Fixes #3906
This commit is contained in:
parent
c9c89a1853
commit
708e810414
|
@ -7,9 +7,15 @@ scriptencoding utf-8
|
||||||
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 = -1
|
||||||
let s:last_pos = [0, 0, 0]
|
let s:last_pos = [0, 0, 0]
|
||||||
|
let s:has_virt_text = 0
|
||||||
|
|
||||||
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')
|
||||||
|
let s:has_virt_text = 1
|
||||||
|
elseif has('textprop') && has('popupwin')
|
||||||
|
call prop_type_add('ale', {})
|
||||||
|
let s:last_popup = -1
|
||||||
|
let s:has_virt_text = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !hlexists('ALEVirtualTextError')
|
if !hlexists('ALEVirtualTextError')
|
||||||
|
@ -33,17 +39,25 @@ if !hlexists('ALEVirtualTextInfo')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! ale#virtualtext#Clear() abort
|
function! ale#virtualtext#Clear() abort
|
||||||
if !has('nvim-0.3.2')
|
if !s:has_virt_text
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:buffer = bufnr('')
|
let l:buffer = bufnr('')
|
||||||
|
|
||||||
|
if has('nvim')
|
||||||
call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
|
call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
|
||||||
|
else
|
||||||
|
if s:last_popup != -1
|
||||||
|
call prop_remove({'type': 'ale'})
|
||||||
|
call popup_close(s:last_popup)
|
||||||
|
let s:last_popup = -1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#virtualtext#ShowMessage(message, hl_group) abort
|
function! ale#virtualtext#ShowMessage(message, hl_group) abort
|
||||||
if !has('nvim-0.3.2')
|
if !s:has_virt_text
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -51,7 +65,24 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort
|
||||||
let l:buffer = bufnr('')
|
let l:buffer = bufnr('')
|
||||||
let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')
|
let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')
|
||||||
|
|
||||||
|
if has('nvim')
|
||||||
call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
|
call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
|
||||||
|
else
|
||||||
|
let l:left_pad = col('$')
|
||||||
|
call prop_add(l:line, l:left_pad, {
|
||||||
|
\ 'type': 'ale',
|
||||||
|
\})
|
||||||
|
let s:last_popup = popup_create(l:prefix.a:message, {
|
||||||
|
\ 'line': -1,
|
||||||
|
\ 'padding': [0, 0, 0, 1],
|
||||||
|
\ 'mask': [[1, 1, 1, 1]],
|
||||||
|
\ 'textprop': 'ale',
|
||||||
|
\ 'highlight': a:hl_group,
|
||||||
|
\ 'fixed': 1,
|
||||||
|
\ 'wrap': 0,
|
||||||
|
\ 'zindex': 2
|
||||||
|
\})
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:StopCursorTimer() abort
|
function! s:StopCursorTimer() abort
|
||||||
|
|
|
@ -2226,8 +2226,6 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor*
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `0`
|
Default: `0`
|
||||||
|
|
||||||
This option only has any effect in NeoVim.
|
|
||||||
|
|
||||||
When this option is set to `1`, a message will be shown when a cursor is
|
When this option is set to `1`, a message will be shown when a cursor is
|
||||||
near a warning or error. ALE will attempt to find the warning or error at a
|
near a warning or error. ALE will attempt to find the warning or error at a
|
||||||
column nearest to the cursor when the cursor is resting on a line which
|
column nearest to the cursor when the cursor is resting on a line which
|
||||||
|
|
Loading…
Reference in New Issue