2017-05-31 21:04:33 +00:00
|
|
|
" Author: w0rp <devw0rp@gmail.com>
|
|
|
|
" Description: balloonexpr support for ALE.
|
|
|
|
|
|
|
|
function! ale#balloon#MessageForPos(bufnr, lnum, col) abort
|
2018-03-25 11:57:08 +00:00
|
|
|
" Don't show balloons if they are disabled, or linting is disabled.
|
|
|
|
if !ale#Var(a:bufnr, 'set_balloons')
|
|
|
|
\|| !g:ale_enabled
|
|
|
|
\|| !getbufvar(a:bufnr, 'ale_enabled', 1)
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
|
2017-05-31 21:04:33 +00:00
|
|
|
let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist
|
2017-08-12 13:27:47 +00:00
|
|
|
let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col)
|
2017-05-31 21:04:33 +00:00
|
|
|
|
|
|
|
return l:index >= 0 ? l:loclist[l:index].text : ''
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale#balloon#Expr() abort
|
|
|
|
return ale#balloon#MessageForPos(v:beval_bufnr, v:beval_lnum, v:beval_col)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale#balloon#Disable() abort
|
2018-03-25 11:57:08 +00:00
|
|
|
set noballooneval balloonexpr=
|
2017-05-31 21:04:33 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale#balloon#Enable() abort
|
|
|
|
set ballooneval balloonexpr=ale#balloon#Expr()
|
|
|
|
endfunction
|