This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/test/test_alelint_autocmd.vader
Martin Tournoij d6bf13502a
Add ALEStartLint autocmd
This grew out of my work in #1193; to ensure the statusline was being
updated I had to add:

    fun! s:redraw(timer)
        redrawstatus
    endfun

    augroup ALEProgress
        autocmd!
        autocmd BufWritePost * call timer_start(100, function('s:redraw'))
        autocmd User ALELint redrawstatus
    augroup end

Which kind of works, but is ugly. With this, I can replace the
`BufWritePost` with:

    autocmd User ALEStartLint redrawstatus

Which is much better, IMHO.

Actually, this patch actually replaces adding a function, since you can
do:

    augroup ALEProgress
        autocmd!
        autocmd User ALEStartLint hi Statusline ctermfg=darkgrey
        autocmd User ALELint      hi Statusline ctermfg=NONE
    augroup end

or:

    let s:ale_running = 0
    let l:stl .= '%{s:ale_running ? "[linting]" : ""}'
    augroup ALEProgress
        autocmd!
        autocmd User ALEStartLint let s:ale_running = 1 | redrawstatus
        autocmd User ALELint      let s:ale_running = 0 | redrawstatus
    augroup end

Both seem to work very well in my testing.

No need to `ale#Statusline#IsRunning()` anymore, I think?
2017-12-07 16:14:20 +00:00

41 lines
953 B
Text

Before:
let g:start = 0
let g:success = 0
let g:ale_run_synchronously = 1
function! TestCallback(buffer, output)
return [{
\ 'lnum': 1,
\ 'col': 3,
\ 'text': 'baz boz',
\}]
endfunction
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
\ 'executable': has('win32') ? 'cmd' : 'true',
\ 'command': has('win32') ? 'echo' : 'true',
\})
"let g:ale_linters = {'foobar': ['lint_file_linter']}
After:
let g:ale_run_synchronously = 0
let g:ale_buffer_info = {}
let g:ale_linters = {}
call ale#linter#Reset()
delfunction TestCallback
augroup! VaderTest
Execute (Run a lint cycle, and check that a variable is set in the autocmd):
set filetype=foobar
augroup VaderTest
autocmd!
autocmd User ALEStartLint let g:start = 1
autocmd User ALELint let g:success = 1
augroup end
call ale#Lint()
AssertEqual g:start, 1
AssertEqual g:success, 1