One of the most annoying details about how InsertLeave behaves in Vim by default is that you can leave insert mode by mashing CTRL+C, and by default this differs from hitting the Escape key in that the former does not trigger an InsertLeave event, while the latter does. Many users resort to writing inoremap <C-c> <Esc> as a result, which allows InsertLeave to be triggered when you leave insert mode. ALE's default is to run linters when you leave insert mode, which happens to be one of the best opportunities to check code, and this default is not applied to anyone with a fresh Vim or Neovim install.
To make the default experience better for users, we can emulate leaving insert mode. When g:ale_lint_on_insert_leave is set to 1, we will add an InsertEnter autocmd event which starts an interval timer. The timer will continue to run until the buffer eventually returns to Normal mode, at which point ALE will start linting. This behaviour will only be enabled if we can detect that <C-c> is not bound to <Esc> and the timer will be killed on an InsertLeave event.
One of the most annoying details about how InsertLeave behaves in Vim by default is that you can leave insert mode by mashing CTRL+C, and by default this differs from hitting the Escape key in that the former does not trigger an
InsertLeave
event, while the latter does. Many users resort to writinginoremap <C-c> <Esc>
as a result, which allowsInsertLeave
to be triggered when you leave insert mode. ALE's default is to run linters when you leave insert mode, which happens to be one of the best opportunities to check code, and this default is not applied to anyone with a fresh Vim or Neovim install.To make the default experience better for users, we can emulate leaving insert mode. When
g:ale_lint_on_insert_leave
is set to1
, we will add anInsertEnter
autocmd event which starts an interval timer. The timer will continue to run until the buffer eventually returns to Normal mode, at which point ALE will start linting. This behaviour will only be enabled if we can detect that<C-c>
is not bound to<Esc>
and the timer will be killed on anInsertLeave
event.