Lint on InsertLeave, not in insert mode by default
b:ale_lint_on_insert_leave is now supported as tests need it. These defaults are saner and cause fewer issues for users by default.
This commit is contained in:
parent
8b46fa3ee7
commit
168768b326
@ -722,11 +722,10 @@ while you type. ALE uses a timeout which is cancelled and reset every time you
|
|||||||
type, and this delay can be increased so linters are run less often. See
|
type, and this delay can be increased so linters are run less often. See
|
||||||
`:help g:ale_lint_delay` for more information.
|
`:help g:ale_lint_delay` for more information.
|
||||||
|
|
||||||
If you don't wish to run linters while you type, you can disable that
|
If you don't wish to run linters while you type, you can disable that behaviour.
|
||||||
behaviour. Set `g:ale_lint_on_text_changed` to `never` or `normal`. You won't
|
Set `g:ale_lint_on_text_changed` to `never`. You won't get as frequent error
|
||||||
get as frequent error checking, but ALE shouldn't block your ability to edit a
|
checking, but ALE shouldn't block your ability to edit a document after you save
|
||||||
document after you save a file, so the asynchronous nature of the plugin will
|
a file, so the asynchronous nature of the plugin will still be an advantage.
|
||||||
still be an advantage.
|
|
||||||
|
|
||||||
If you are still concerned, you can turn the automatic linting off altogether,
|
If you are still concerned, you can turn the automatic linting off altogether,
|
||||||
including the option `g:ale_lint_on_enter`, and you can run ALE manually with
|
including the option `g:ale_lint_on_enter`, and you can run ALE manually with
|
||||||
|
@ -128,7 +128,7 @@ function! ale#events#Init() abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if g:ale_lint_on_insert_leave
|
if g:ale_lint_on_insert_leave
|
||||||
autocmd InsertLeave * call ale#Queue(0)
|
autocmd InsertLeave * if ale#Var(str2nr(expand('<abuf>')), 'lint_on_insert_leave') | call ale#Queue(0) | endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:ale_echo_cursor || g:ale_cursor_detail
|
if g:ale_echo_cursor || g:ale_cursor_detail
|
||||||
|
@ -84,7 +84,7 @@ have even saved your changes. ALE will check your code in the following
|
|||||||
circumstances, which can be configured with the associated options.
|
circumstances, which can be configured with the associated options.
|
||||||
|
|
||||||
* When you modify a buffer. - |g:ale_lint_on_text_changed|
|
* When you modify a buffer. - |g:ale_lint_on_text_changed|
|
||||||
* On leaving insert mode. (off by default) - |g:ale_lint_on_insert_leave|
|
* On leaving insert mode. - |g:ale_lint_on_insert_leave|
|
||||||
* When you open a new or modified buffer. - |g:ale_lint_on_enter|
|
* When you open a new or modified buffer. - |g:ale_lint_on_enter|
|
||||||
* When you save a buffer. - |g:ale_lint_on_save|
|
* When you save a buffer. - |g:ale_lint_on_save|
|
||||||
* When the filetype changes for a buffer. - |g:ale_lint_on_filetype_changed|
|
* When the filetype changes for a buffer. - |g:ale_lint_on_filetype_changed|
|
||||||
@ -953,7 +953,7 @@ g:ale_lint_on_save *g:ale_lint_on_save*
|
|||||||
g:ale_lint_on_text_changed *g:ale_lint_on_text_changed*
|
g:ale_lint_on_text_changed *g:ale_lint_on_text_changed*
|
||||||
|
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'always'`
|
Default: `'normal'`
|
||||||
|
|
||||||
This option controls how ALE will check your files as you make changes.
|
This option controls how ALE will check your files as you make changes.
|
||||||
The following values can be used.
|
The following values can be used.
|
||||||
@ -978,6 +978,7 @@ g:ale_lint_on_text_changed *g:ale_lint_on_text_changed*
|
|||||||
|
|
||||||
|
|
||||||
g:ale_lint_on_insert_leave *g:ale_lint_on_insert_leave*
|
g:ale_lint_on_insert_leave *g:ale_lint_on_insert_leave*
|
||||||
|
*b:ale_lint_on_insert_leave*
|
||||||
|
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `0`
|
Default: `0`
|
||||||
@ -992,6 +993,10 @@ g:ale_lint_on_insert_leave *g:ale_lint_on_insert_leave*
|
|||||||
" Make using Ctrl+C do the same as Escape, to trigger autocmd commands
|
" Make using Ctrl+C do the same as Escape, to trigger autocmd commands
|
||||||
inoremap <C-c> <Esc>
|
inoremap <C-c> <Esc>
|
||||||
<
|
<
|
||||||
|
A buffer-local version of this setting `b:ale_lint_on_insert_leave` can be
|
||||||
|
set to `0` to disable linting when leaving insert mode. The setting must
|
||||||
|
be enabled globally to be enabled locally.
|
||||||
|
|
||||||
You should set this setting once before ALE is loaded, and restart Vim if
|
You should set this setting once before ALE is loaded, and restart Vim if
|
||||||
you want to change your preferences. See |ale-lint-settings-on-startup|.
|
you want to change your preferences. See |ale-lint-settings-on-startup|.
|
||||||
|
|
||||||
|
@ -71,12 +71,12 @@ let g:ale_linter_aliases = get(g:, 'ale_linter_aliases', {})
|
|||||||
let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200)
|
let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200)
|
||||||
|
|
||||||
" This flag can be set to 'never' to disable linting when text is changed.
|
" This flag can be set to 'never' to disable linting when text is changed.
|
||||||
" This flag can also be set to 'insert' or 'normal' to lint when text is
|
" This flag can also be set to 'always' or 'insert' to lint when text is
|
||||||
" changed only in insert or normal mode respectively.
|
" changed in both normal and insert mode, or only in insert mode respectively.
|
||||||
let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 'always')
|
let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 'normal')
|
||||||
|
|
||||||
" This flag can be set to 1 to enable linting when leaving insert mode.
|
" This flag can be set to 1 to enable linting when leaving insert mode.
|
||||||
let g:ale_lint_on_insert_leave = get(g:, 'ale_lint_on_insert_leave', 0)
|
let g:ale_lint_on_insert_leave = get(g:, 'ale_lint_on_insert_leave', 1)
|
||||||
|
|
||||||
" This flag can be set to 0 to disable linting when the buffer is entered.
|
" This flag can be set to 0 to disable linting when the buffer is entered.
|
||||||
let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1)
|
let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1)
|
||||||
|
@ -31,8 +31,8 @@ Before:
|
|||||||
let g:ale_completion_enabled = 0
|
let g:ale_completion_enabled = 0
|
||||||
let g:ale_completion_max_suggestions = 50
|
let g:ale_completion_max_suggestions = 50
|
||||||
let g:ale_history_log_output = 1
|
let g:ale_history_log_output = 1
|
||||||
let g:ale_lint_on_insert_leave = 0
|
let g:ale_lint_on_insert_leave = 1
|
||||||
let g:ale_lint_on_text_changed = 'always'
|
let g:ale_lint_on_text_changed = 'normal'
|
||||||
let g:ale_lsp_error_messages = {}
|
let g:ale_lsp_error_messages = {}
|
||||||
let g:ale_maximum_file_size = 0
|
let g:ale_maximum_file_size = 0
|
||||||
let g:ale_pattern_options = {}
|
let g:ale_pattern_options = {}
|
||||||
@ -88,9 +88,9 @@ Before:
|
|||||||
\ 'let g:ale_lint_delay = 200',
|
\ 'let g:ale_lint_delay = 200',
|
||||||
\ 'let g:ale_lint_on_enter = 1',
|
\ 'let g:ale_lint_on_enter = 1',
|
||||||
\ 'let g:ale_lint_on_filetype_changed = 1',
|
\ 'let g:ale_lint_on_filetype_changed = 1',
|
||||||
\ 'let g:ale_lint_on_insert_leave = 0',
|
\ 'let g:ale_lint_on_insert_leave = 1',
|
||||||
\ 'let g:ale_lint_on_save = 1',
|
\ 'let g:ale_lint_on_save = 1',
|
||||||
\ 'let g:ale_lint_on_text_changed = ''always''',
|
\ 'let g:ale_lint_on_text_changed = ''normal''',
|
||||||
\ 'let g:ale_linter_aliases = {}',
|
\ 'let g:ale_linter_aliases = {}',
|
||||||
\ 'let g:ale_linters = {}',
|
\ 'let g:ale_linters = {}',
|
||||||
\ 'let g:ale_linters_explicit = 0',
|
\ 'let g:ale_linters_explicit = 0',
|
||||||
|
@ -87,7 +87,7 @@ Execute (All events should be set up when everything is on):
|
|||||||
\ 'CursorMoved * if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarningWithDelay() | endif',
|
\ 'CursorMoved * if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarningWithDelay() | endif',
|
||||||
\ 'FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''<abuf>'')))',
|
\ 'FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''<abuf>'')))',
|
||||||
\ 'FileType * call ale#events#FileTypeEvent( str2nr(expand(''<abuf>'')), expand(''<amatch>''))',
|
\ 'FileType * call ale#events#FileTypeEvent( str2nr(expand(''<abuf>'')), expand(''<amatch>''))',
|
||||||
\ 'InsertLeave * call ale#Queue(0)',
|
\ 'InsertLeave * if ale#Var(str2nr(expand(''<abuf>'')), ''lint_on_insert_leave'') | call ale#Queue(0) | endif',
|
||||||
\ 'InsertLeave if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarning() | endif',
|
\ 'InsertLeave if exists(''*ale#engine#Cleanup'') | call ale#cursor#EchoCursorWarning() | endif',
|
||||||
\ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
|
\ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
|
||||||
\ 'TextChangedI * call ale#Queue(g:ale_lint_delay)',
|
\ 'TextChangedI * call ale#Queue(g:ale_lint_delay)',
|
||||||
@ -158,7 +158,7 @@ Execute (g:ale_lint_on_insert_leave = 1 should bind InsertLeave):
|
|||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
\ 'InsertLeave * call ale#Queue(0)',
|
\ 'InsertLeave * if ale#Var(str2nr(expand(''<abuf>'')), ''lint_on_insert_leave'') | call ale#Queue(0) | endif',
|
||||||
\ ],
|
\ ],
|
||||||
\ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''^InsertLeave''')
|
\ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''^InsertLeave''')
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
Before:
|
Before:
|
||||||
Save g:ale_echo_msg_format
|
Save g:ale_echo_msg_format
|
||||||
Save g:ale_echo_cursor
|
Save g:ale_echo_cursor
|
||||||
|
Save b:ale_lint_on_insert_leave
|
||||||
|
|
||||||
|
let g:ale_echo_msg_format = '%code: %%s'
|
||||||
|
let b:ale_lint_on_insert_leave = 0
|
||||||
|
|
||||||
" We should prefer the error message at column 10 instead of the warning.
|
" We should prefer the error message at column 10 instead of the warning.
|
||||||
let g:ale_buffer_info = {
|
let g:ale_buffer_info = {
|
||||||
@ -91,6 +95,9 @@ Before:
|
|||||||
return empty(l:lines) ? '' : l:lines[-1]
|
return empty(l:lines) ? '' : l:lines[-1]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Reset()
|
||||||
|
call ale#linter#PreventLoading('javascript')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
@ -117,6 +124,8 @@ After:
|
|||||||
noautocmd :q!
|
noautocmd :q!
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
Given javascript(A Javscript file with warnings/errors):
|
Given javascript(A Javscript file with warnings/errors):
|
||||||
var x = 3 + 12345678
|
var x = 3 + 12345678
|
||||||
var x = 5*2 + parseInt("10");
|
var x = 5*2 + parseInt("10");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user