diff options
author | Chris Marchesi <chrism@vancluevertech.com> | 2018-04-27 15:40:02 -0700 |
---|---|---|
committer | Chris Marchesi <chrism@vancluevertech.com> | 2018-04-27 15:40:02 -0700 |
commit | b7996803c99a0a5f5dba1cef330a2bfb77f08c42 (patch) | |
tree | 8e20950cfd4cb24bf1eeb97a3528b8ec8db16e58 | |
parent | e6fe2d86b8bbdcc5a5d27bd4ac30fd30c8cc62ee (diff) | |
download | ale-b7996803c99a0a5f5dba1cef330a2bfb77f08c42.zip |
Add ALEJobStarted User autocommand event
The ALELintPre and ALELintPost autocommand events are currently being
used by lightline-ale to refresh the status line and check the linter
status for a current buffer. One of the plugin's checks looks to see if
linters are currently running, via ale#engine#IsCheckingBuffer(). This
currently only works partially in certain situations. In my particular
case, working with Go files, this only seems to function properly when a
file is initially opened. Saving a file does not correctly update the
status.
This seems to be due to the fact that ALELintPre actually runs before
any jobs are carried out, making it plausible that hooking into
ALELintPre for the purpose of checking to see if there are any currently
running linters for a buffer is unreliable as it would be prone to
pretty obvious race conditions.
This adds a new User autocommand, ALEJobStarted, that gets fired at the
start of every new job that is successfully run. This allows a better
point to hook into checking the linter status of a buffer using
ale#engine#IsCheckingBuffer() by ensuring that at least one job has
started by the time IsCheckingBuffer is run.
-rw-r--r-- | autoload/ale/engine.vim | 2 | ||||
-rw-r--r-- | doc/ale.txt | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 0704fd5b..e1c41552 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -586,6 +586,8 @@ function! s:RunJob(options) abort \ 'output': [], \ 'next_chain_index': l:next_chain_index, \} + + silent doautocmd <nomodeline> User ALEJobStarted endif if g:ale_history_enabled diff --git a/doc/ale.txt b/doc/ale.txt index de6507e3..d52e8fe9 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2452,7 +2452,14 @@ ALEFixPost *ALEFixPost-autocmd* autocmd User ALELintPre let s:ale_running = 1 | redrawstatus autocmd User ALELintPost let s:ale_running = 0 | redrawstatus augroup end + < +ALEJobStarted *ALEJobStarted-autocmd* + + This |User| autocommand is triggered immediately after a job is successfully + run. This provides better accuracy for checking linter status with + |ale#engine#IsCheckingBuffer()| over |ALELintPre|, which is actually + triggered before any linters are executed. =============================================================================== 10. Special Thanks *ale-special-thanks* |