mirror of
https://github.com/dense-analysis/ale
synced 2024-12-28 17:12:23 +00:00
89 lines
1.9 KiB
Plaintext
89 lines
1.9 KiB
Plaintext
Before:
|
|
Save g:ale_set_lists_synchronously
|
|
Save g:ale_buffer_info
|
|
|
|
let g:ale_buffer_info = {}
|
|
let g:ale_set_lists_synchronously = 1
|
|
|
|
function! TestCallback(buffer, output)
|
|
" Windows adds extra spaces to the text from echo.
|
|
return [{
|
|
\ 'lnum': 2,
|
|
\ 'col': 3,
|
|
\ 'text': substitute(a:output[0], ' *$', '', ''),
|
|
\}]
|
|
endfunction
|
|
function! TestCallback2(buffer, output)
|
|
return [{
|
|
\ 'lnum': 3,
|
|
\ 'col': 4,
|
|
\ 'text': substitute(a:output[0], ' *$', '', ''),
|
|
\}]
|
|
endfunction
|
|
|
|
" Running the command in another subshell seems to help here.
|
|
call ale#linter#Define('foobar', {
|
|
\ 'name': 'testlinter',
|
|
\ 'callback': 'TestCallback',
|
|
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
|
\ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
|
|
\})
|
|
|
|
After:
|
|
Restore
|
|
|
|
delfunction TestCallback
|
|
delfunction TestCallback2
|
|
call ale#linter#Reset()
|
|
|
|
Given foobar (Some imaginary filetype):
|
|
foo
|
|
bar
|
|
baz
|
|
|
|
Execute(Linters should run with the default options):
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
call ale#Lint()
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
AssertEqual [{
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'lnum': 2,
|
|
\ 'vcol': 0,
|
|
\ 'col': 3,
|
|
\ 'text': 'foo bar',
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'pattern': '',
|
|
\ 'valid': 1,
|
|
\ }], getloclist(0)
|
|
|
|
Execute(Previous errors should be removed when linters change):
|
|
call ale#Lint()
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
call ale#linter#Reset()
|
|
|
|
call ale#linter#Define('foobar', {
|
|
\ 'name': 'testlinter2',
|
|
\ 'callback': 'TestCallback2',
|
|
\ 'executable': has('win32') ? 'cmd' : 'echo',
|
|
\ 'command': has('win32') ? 'echo baz boz' : '/bin/sh -c ''echo baz boz''',
|
|
\})
|
|
|
|
call ale#Lint()
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
AssertEqual [{
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'lnum': 3,
|
|
\ 'vcol': 0,
|
|
\ 'col': 4,
|
|
\ 'text': 'baz boz',
|
|
\ 'type': 'E',
|
|
\ 'nr': -1,
|
|
\ 'pattern': '',
|
|
\ 'valid': 1,
|
|
\ }], getloclist(0)
|