summaryrefslogtreecommitdiff
path: root/autoload/ale/engine.vim
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@users.noreply.github.com>2023-01-29 17:25:09 +0000
committerGitHub <noreply@github.com>2023-01-29 17:25:09 +0000
commit116d713f63c7a81663fa53efa10e34649c9479e3 (patch)
tree0ca5ed37b4320e70901de6b9bcafee53c259a2aa /autoload/ale/engine.vim
parent0af4899605af26dd8ea7fe79acff6ab99f6532b2 (diff)
downloadale-116d713f63c7a81663fa53efa10e34649c9479e3.zip
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>
Diffstat (limited to 'autoload/ale/engine.vim')
-rw-r--r--autoload/ale/engine.vim27
1 files changed, 23 insertions, 4 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 150bbc82..185d54db 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -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