diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/events.vim | 79 |
1 files changed, 27 insertions, 52 deletions
diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim index 7cdc2e8e..44ef4b7a 100644 --- a/autoload/ale/events.vim +++ b/autoload/ale/events.vim @@ -83,13 +83,13 @@ function! ale#events#Init() abort " This value used to be a Boolean as a Number, and is now a String. let l:text_changed = '' . g:ale_lint_on_text_changed - augroup ALEPatternOptionsGroup + augroup ALEEvents autocmd! + + " These events always need to be set up. autocmd BufEnter,BufRead * call ale#pattern_options#SetOptions(str2nr(expand('<abuf>'))) - augroup END + autocmd BufWritePost * call ale#events#SaveEvent(str2nr(expand('<abuf>'))) - augroup ALERunOnTextChangedGroup - autocmd! if g:ale_enabled if l:text_changed is? 'always' || l:text_changed is# '1' autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay) @@ -98,61 +98,36 @@ function! ale#events#Init() abort elseif l:text_changed is? 'insert' autocmd TextChangedI * call ale#Queue(g:ale_lint_delay) endif - endif - augroup END - augroup ALERunOnEnterGroup - autocmd! - if g:ale_enabled " Handle everything that needs to happen when buffers are entered. autocmd BufEnter * call ale#events#EnterEvent(str2nr(expand('<abuf>'))) - endif - if g:ale_enabled && g:ale_lint_on_enter - autocmd BufWinEnter,BufRead * call ale#Queue(0, 'lint_file', str2nr(expand('<abuf>'))) - " Track when the file is changed outside of Vim. - autocmd FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand('<abuf>'))) - endif - augroup END - augroup ALERunOnFiletypeChangeGroup - autocmd! - if g:ale_enabled && g:ale_lint_on_filetype_changed - " Only start linting if the FileType actually changes after - " opening a buffer. The FileType will fire when buffers are opened. - autocmd FileType * call ale#events#FileTypeEvent( - \ str2nr(expand('<abuf>')), - \ expand('<amatch>') - \) - endif - augroup END + if g:ale_lint_on_enter + autocmd BufWinEnter,BufRead * call ale#Queue(0, 'lint_file', str2nr(expand('<abuf>'))) + " Track when the file is changed outside of Vim. + autocmd FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand('<abuf>'))) + endif - augroup ALERunOnSaveGroup - autocmd! - autocmd BufWritePost * call ale#events#SaveEvent(str2nr(expand('<abuf>'))) - augroup END + if g:ale_lint_on_filetype_changed + " Only start linting if the FileType actually changes after + " opening a buffer. The FileType will fire when buffers are opened. + autocmd FileType * call ale#events#FileTypeEvent( + \ str2nr(expand('<abuf>')), + \ expand('<amatch>') + \) + endif - augroup ALERunOnInsertLeave - autocmd! - if g:ale_enabled && g:ale_lint_on_insert_leave - autocmd InsertLeave * call ale#Queue(0) - endif - augroup END + if g:ale_lint_on_insert_leave + autocmd InsertLeave * call ale#Queue(0) + endif - augroup ALECursorGroup - autocmd! - if g:ale_enabled && g:ale_echo_cursor - autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay() - " Look for a warning to echo as soon as we leave Insert mode. - " The script's position variable used when moving the cursor will - " not be changed here. - autocmd InsertLeave * call ale#cursor#EchoCursorWarning() + if g:ale_echo_cursor + autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay() + " Look for a warning to echo as soon as we leave Insert mode. + " The script's position variable used when moving the cursor will + " not be changed here. + autocmd InsertLeave * call ale#cursor#EchoCursorWarning() + endif endif augroup END - - if !g:ale_enabled - augroup! ALERunOnTextChangedGroup - augroup! ALERunOnEnterGroup - augroup! ALERunOnInsertLeave - augroup! ALECursorGroup - endif endfunction |