All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: w0rp <devw0rp@gmail.com>
2 " Description: balloonexpr support for ALE.
4 function! ale#balloon#MessageForPos(bufnr, lnum, col) abort
5 let l:set_balloons = ale#Var(a:bufnr, 'set_balloons')
6 let l:show_problems = 0
10 let l:show_problems = 1
12 elseif l:set_balloons is# 'hover'
16 " Don't show balloons if they are disabled, or linting is disabled.
17 if !(l:show_problems || l:show_hover)
19 \|| !getbufvar(a:bufnr, 'ale_enabled', 1)
24 let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist
25 let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col)
28 " Show the diagnostics message if found, 'Hover' output otherwise
29 if l:show_problems && l:index >= 0
30 return l:loclist[l:index].text
31 elseif l:show_hover && (
32 \ exists('*balloon_show')
35 \ 'ale_set_balloons_legacy_echo',
36 \ get(g:, 'ale_set_balloons_legacy_echo', 0)
39 " Request LSP/tsserver hover information, but only if this version of
40 " Vim supports the balloon_show function, or if we turned a legacy
42 call ale#hover#Show(a:bufnr, a:lnum, a:col, {'called_from_balloonexpr': 1})
48 function! ale#balloon#Expr() abort
49 return ale#balloon#MessageForPos(v:beval_bufnr, v:beval_lnum, v:beval_col)
52 function! ale#balloon#Disable() abort
53 if has('balloon_eval')
58 if has('balloon_eval_term')
64 function! ale#balloon#Enable() abort
65 if has('balloon_eval')
67 set balloonexpr=ale#balloon#Expr()
70 if has('balloon_eval_term')
72 set balloonexpr=ale#balloon#Expr()