mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-16 01:07:06 +08:00
diagnostics: support sending ALE output to Neovim's diagnostics API (#4345)
Support replacing ALE's display of problems with sending problems to the Neovim diagnostics API. :help g:ale_use_neovim_diagnostics_api Co-authored-by: David Balatero <dbalatero@users.noreply.github.com> Co-authored-by: Georgi Angelchev <angelchev@live.co.uk> Co-authored-by: w0rp <devw0rp@gmail.com>
This commit is contained in:
@@ -55,6 +55,7 @@ let s:global_variable_list = [
|
||||
\ 'ale_sign_highlight_linenrs',
|
||||
\ 'ale_statusline_format',
|
||||
\ 'ale_type_map',
|
||||
\ 'ale_use_neovim_diagnostics_api',
|
||||
\ 'ale_use_global_executables',
|
||||
\ 'ale_virtualtext_cursor',
|
||||
\ 'ale_warn_about_trailing_blank_lines',
|
||||
|
||||
@@ -184,9 +184,13 @@ endfunction
|
||||
function! ale#engine#SetResults(buffer, loclist) abort
|
||||
let l:linting_is_done = !ale#engine#IsCheckingBuffer(a:buffer)
|
||||
|
||||
if g:ale_use_neovim_diagnostics_api
|
||||
call ale#engine#SendResultsToNeovimDiagnostics(a:buffer, a:loclist)
|
||||
endif
|
||||
|
||||
" Set signs first. This could potentially fix some line numbers.
|
||||
" The List could be sorted again here by SetSigns.
|
||||
if g:ale_set_signs
|
||||
if !g:ale_use_neovim_diagnostics_api && g:ale_set_signs
|
||||
call ale#sign#SetSigns(a:buffer, a:loclist)
|
||||
endif
|
||||
|
||||
@@ -199,11 +203,12 @@ function! ale#engine#SetResults(buffer, loclist) abort
|
||||
call ale#statusline#Update(a:buffer, a:loclist)
|
||||
endif
|
||||
|
||||
if g:ale_set_highlights
|
||||
if !g:ale_use_neovim_diagnostics_api && g:ale_set_highlights
|
||||
call ale#highlight#SetHighlights(a:buffer, a:loclist)
|
||||
endif
|
||||
|
||||
if g:ale_virtualtext_cursor is# 'all' || g:ale_virtualtext_cursor == 2
|
||||
if !g:ale_use_neovim_diagnostics_api
|
||||
\&& (g:ale_virtualtext_cursor is# 'all' || g:ale_virtualtext_cursor == 2)
|
||||
call ale#virtualtext#SetTexts(a:buffer, a:loclist)
|
||||
endif
|
||||
|
||||
@@ -214,7 +219,8 @@ function! ale#engine#SetResults(buffer, loclist) abort
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
endif
|
||||
|
||||
if g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor == 1
|
||||
if !g:ale_use_neovim_diagnostics_api
|
||||
\&& (g:ale_virtualtext_cursor is# 'current' || g:ale_virtualtext_cursor == 1)
|
||||
" Try and show the warning now.
|
||||
" This will only do something meaningful if we're in normal mode.
|
||||
call ale#virtualtext#ShowCursorWarning()
|
||||
@@ -238,6 +244,19 @@ function! ale#engine#SetResults(buffer, loclist) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#engine#SendResultsToNeovimDiagnostics(buffer, loclist) abort
|
||||
if !has('nvim-0.6')
|
||||
" We will warn the user on startup as well if they try to set
|
||||
" g:ale_use_neovim_diagnostics_api outside of a Neovim context.
|
||||
return
|
||||
endif
|
||||
|
||||
" Keep the Lua surface area really small in the VimL part of ALE,
|
||||
" and just require the diagnostics.lua module on demand.
|
||||
let l:SendDiagnostics = luaeval('require("diagnostics").sendAleResultsToDiagnostics')
|
||||
call l:SendDiagnostics(a:buffer, a:loclist)
|
||||
endfunction
|
||||
|
||||
function! s:RemapItemTypes(type_map, loclist) abort
|
||||
for l:item in a:loclist
|
||||
let l:key = l:item.type
|
||||
|
||||
@@ -187,10 +187,8 @@ function! ale#virtualtext#ShowCursorWarning(...) abort
|
||||
let l:buffer = bufnr('')
|
||||
|
||||
if mode(1) isnot# 'n'
|
||||
return
|
||||
endif
|
||||
|
||||
if ale#ShouldDoNothing(l:buffer)
|
||||
\|| g:ale_use_neovim_diagnostics_api
|
||||
\|| ale#ShouldDoNothing(l:buffer)
|
||||
return
|
||||
endif
|
||||
|
||||
@@ -210,12 +208,13 @@ function! ale#virtualtext#ShowCursorWarningWithDelay() abort
|
||||
return
|
||||
endif
|
||||
|
||||
call s:StopCursorTimer()
|
||||
|
||||
if mode(1) isnot# 'n'
|
||||
\|| g:ale_use_neovim_diagnostics_api
|
||||
return
|
||||
endif
|
||||
|
||||
call s:StopCursorTimer()
|
||||
|
||||
let l:pos = getpos('.')[0:2]
|
||||
|
||||
" Check the current buffer, line, and column number against the last
|
||||
|
||||
Reference in New Issue
Block a user