2023-09-05 13:34:33 +00:00
|
|
|
Before:
|
|
|
|
Save g:ale_use_neovim_diagnostics_api
|
|
|
|
|
|
|
|
function! CollectMessages(buffer)
|
|
|
|
let l:messages = []
|
|
|
|
for l:diag in v:lua.vim.diagnostic.get(a:buffer)
|
|
|
|
call add(l:messages, l:diag.message)
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:messages
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
After:
|
|
|
|
unlet! b:other_bufnr
|
|
|
|
delfunction CollectMessages
|
|
|
|
Restore
|
|
|
|
|
|
|
|
Execute(Should only set diagnostics belonging to the given buffer):
|
|
|
|
if has('nvim-0.6')
|
2023-09-07 18:59:05 +00:00
|
|
|
let b:other_bufnr = bufnr('/foo/bar/baz', 1)
|
|
|
|
" Make sure we actually get another buffer number, or the test is invalid.
|
|
|
|
AssertNotEqual -1, b:other_bufnr
|
2023-09-05 13:34:33 +00:00
|
|
|
|
2023-09-07 18:59:05 +00:00
|
|
|
let g:ale_use_neovim_diagnostics_api = 1
|
2023-09-05 13:34:33 +00:00
|
|
|
|
2023-09-07 18:59:05 +00:00
|
|
|
call ale#engine#SetResults(bufnr('%'), [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 10,
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'bettercode',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'A',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 10,
|
|
|
|
\ 'bufnr': b:other_bufnr,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'bettercode',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'B',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 3,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'bettercode',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'C',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 4,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'bufnr': b:other_bufnr,
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'bettercode',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'D',
|
|
|
|
\ },
|
|
|
|
\])
|
2023-09-05 13:34:33 +00:00
|
|
|
|
2023-09-07 18:59:05 +00:00
|
|
|
AssertEqual ["A", "C"], CollectMessages(bufnr('%'))
|
2023-09-05 13:34:33 +00:00
|
|
|
endif
|