diff options
author | w0rp <devw0rp@gmail.com> | 2019-05-16 20:04:18 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-05-16 20:04:18 +0100 |
commit | d0f2a0ae940ef67649453de40c0ca3488d4dcec4 (patch) | |
tree | 83f9cdd6a2504e5074541fedfa8e1dd32212c4ff /autoload | |
parent | 9b89ec3d863f3fa4d24d8597163df98aa5bf2c74 (diff) | |
download | ale-d0f2a0ae940ef67649453de40c0ca3488d4dcec4.zip |
Fix #2505 - Remove NeoVim highlight support for now
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/highlight.vim | 128 |
1 files changed, 16 insertions, 112 deletions
diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim index f228aa44..3ce6bff4 100644 --- a/autoload/ale/highlight.vim +++ b/autoload/ale/highlight.vim @@ -26,41 +26,6 @@ endif let s:MAX_POS_VALUES = 8 let s:MAX_COL_SIZE = 1073741824 " pow(2, 30) -" Check if we have neovim's buffer highlight API -" -" Below we define some functions' implementation conditionally if this API -" exists or not. -" -" The API itself is more ergonomic and neovim performs highlights positions -" rebases during edits so we see less stalled highlights. -let s:nvim_api = exists('*nvim_buf_add_highlight') && exists('*nvim_buf_clear_namespace') - -function! ale#highlight#HasNeovimApi() abort - return s:nvim_api -endfunction - -function! ale#highlight#nvim_buf_clear_namespace(...) abort - return call('nvim_buf_clear_namespace', a:000) -endfunction - -function! ale#highlight#nvim_buf_add_highlight(...) abort - return call('nvim_buf_add_highlight', a:000) -endfunction - -function! s:ale_nvim_highlight_id(bufnr) abort - let l:id = getbufvar(a:bufnr, 'ale_nvim_highlight_id', -1) - - if l:id is -1 - " NOTE: This will highlight nothing but will allocate new id - let l:id = ale#highlight#nvim_buf_add_highlight( - \ a:bufnr, 0, '', 0, 0, -1 - \) - call setbufvar(a:bufnr, 'ale_nvim_highlight_id', l:id) - endif - - return l:id -endfunction - function! ale#highlight#CreatePositions(line, col, end_line, end_col) abort if a:line >= a:end_line " For single lines, just return the one position. @@ -86,90 +51,29 @@ endfunction " except these which have matching loclist item entries. function! ale#highlight#RemoveHighlights() abort - if ale#highlight#HasNeovimApi() - if get(b:, 'ale_nvim_highlight_id', 0) - let l:bufnr = bufnr('%') - " NOTE: 0, -1 means from 0 line till the end of buffer - call ale#highlight#nvim_buf_clear_namespace( - \ l:bufnr, - \ b:ale_nvim_highlight_id, - \ 0, -1 - \) + for l:match in getmatches() + if l:match.group =~# '^ALE' + call matchdelete(l:match.id) endif - else - for l:match in getmatches() - if l:match.group =~# '^ALE' - call matchdelete(l:match.id) - endif - endfor - endif + endfor endfunction function! s:highlight_line(bufnr, lnum, group) abort - if ale#highlight#HasNeovimApi() - let l:highlight_id = s:ale_nvim_highlight_id(a:bufnr) - call ale#highlight#nvim_buf_add_highlight( - \ a:bufnr, l:highlight_id, a:group, - \ a:lnum - 1, 0, -1 - \) - else - call matchaddpos(a:group, [a:lnum]) - endif + call matchaddpos(a:group, [a:lnum]) endfunction function! s:highlight_range(bufnr, range, group) abort - if ale#highlight#HasNeovimApi() - let l:line_count = len(getbufline(a:bufnr, 1, '$')) - - let l:highlight_id = s:ale_nvim_highlight_id(a:bufnr) - " NOTE: lines and columns indicies are 0-based in nvim_buf_* API. - let l:lnum = a:range.lnum - 1 - let l:end_lnum = min([a:range.end_lnum, l:line_count]) - 1 - let l:col = a:range.col - 1 - let l:end_col = a:range.end_col - - if l:lnum is l:end_lnum - " For single lines, just return the one position. - call ale#highlight#nvim_buf_add_highlight( - \ a:bufnr, l:highlight_id, a:group, - \ l:lnum, l:col, l:end_col - \) - elseif l:lnum < l:end_lnum - " highlight first line from start till the line end - call ale#highlight#nvim_buf_add_highlight( - \ a:bufnr, l:highlight_id, a:group, - \ l:lnum, l:col, -1 - \) - - " highlight all lines between the first and last entirely - let l:cur = l:lnum + 1 - - while l:cur < l:end_lnum - call ale#highlight#nvim_buf_add_highlight( - \ a:bufnr, l:highlight_id, a:group, - \ l:cur, 0, -1 - \ ) - let l:cur += 1 - endwhile - - call ale#highlight#nvim_buf_add_highlight( - \ a:bufnr, l:highlight_id, a:group, - \ l:end_lnum, 0, l:end_col - \) - endif - else - " Set all of the positions, which are chunked into Lists which - " are as large as will be accepted by matchaddpos. - call map( - \ ale#highlight#CreatePositions( - \ a:range.lnum, - \ a:range.col, - \ a:range.end_lnum, - \ a:range.end_col - \ ), - \ 'matchaddpos(a:group, v:val)' - \) - endif + " Set all of the positions, which are chunked into Lists which + " are as large as will be accepted by matchaddpos. + call map( + \ ale#highlight#CreatePositions( + \ a:range.lnum, + \ a:range.col, + \ a:range.end_lnum, + \ a:range.end_col + \ ), + \ 'matchaddpos(a:group, v:val)' + \) endfunction function! ale#highlight#UpdateHighlights() abort |