summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authortaylorskalyo <taylorskalyo@users.noreply.github.com>2017-03-30 18:21:37 -0400
committerw0rp <w0rp@users.noreply.github.com>2017-03-30 23:21:37 +0100
commit36f9631512fe164ae115c4a216d3cddbf81e6daa (patch)
tree053e4741faeb285bf34d880a539c803f789f67ee /plugin
parent3a74d242f9b2b09dd066e5cfd6ed9a0149395b87 (diff)
downloadale-36f9631512fe164ae115c4a216d3cddbf81e6daa.zip
Add options to facilitate linting only in normal mode (#425)
* [#420] Add options to facilitate linting only in normal mode ale_lint_on_text_changed: Allow setting to 'insert' or 'normal' to lint when text is changed only in insert or normal mode respectively. ale_lint_on_insert_leave: This flag can be set to 1 to enable linting when leaving insert mode. * [#420] Test updated global options Ale should - bind to TextChanged events when g:ale_lint_on_text_changed = 1 - bind to TextChanged events when g:ale_lint_on_text_changed = 'always' - bind to InsertLeave event when g:ale_lint_on_insert_leave = 1
Diffstat (limited to 'plugin')
-rw-r--r--plugin/ale.vim33
1 files changed, 26 insertions, 7 deletions
diff --git a/plugin/ale.vim b/plugin/ale.vim
index d728854c..6c044e8f 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -69,8 +69,13 @@ let g:ale_linter_aliases = get(g:, 'ale_linter_aliases', {})
" jobs for linting until enough time has passed after editing is done.
let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200)
-" This flag can be set to 0 to disable linting when text is changed.
-let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 1)
+" 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
+" changed only in insert or normal mode respectively.
+let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 'always')
+
+" 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)
" 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)
@@ -149,11 +154,17 @@ let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1)
" A flag for storing the full output of commands in the history.
let g:ale_history_log_output = get(g:, 'ale_history_log_output', 0)
-function! s:ALEInitAuGroups() abort
+function! ALEInitAuGroups() abort
augroup ALERunOnTextChangedGroup
autocmd!
- if g:ale_enabled && g:ale_lint_on_text_changed
- autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
+ if g:ale_enabled
+ if g:ale_lint_on_text_changed ==? 'always' || g:ale_lint_on_text_changed == 1
+ autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
+ elseif g:ale_lint_on_text_changed ==? 'normal'
+ autocmd TextChanged * call ale#Queue(g:ale_lint_delay)
+ elseif g:ale_lint_on_text_changed ==? 'insert'
+ autocmd TextChangedI * call ale#Queue(g:ale_lint_delay)
+ endif
endif
augroup END
@@ -178,6 +189,13 @@ function! s:ALEInitAuGroups() abort
endif
augroup END
+ augroup ALERunOnInsertLeave
+ autocmd!
+ if g:ale_enabled && g:ale_lint_on_insert_leave
+ autocmd InsertLeave * call ale#Queue(0, 'lint_file')
+ endif
+ augroup END
+
augroup ALECursorGroup
autocmd!
if g:ale_enabled && g:ale_echo_cursor
@@ -193,6 +211,7 @@ function! s:ALEInitAuGroups() abort
augroup! ALERunOnTextChangedGroup
augroup! ALERunOnEnterGroup
augroup! ALERunOnSaveGroup
+ augroup! ALERunOnInsertLeave
augroup! ALECursorGroup
endif
endfunction
@@ -219,10 +238,10 @@ function! s:ALEToggle() abort
endif
endif
- call s:ALEInitAuGroups()
+ call ALEInitAuGroups()
endfunction
-call s:ALEInitAuGroups()
+call ALEInitAuGroups()
" Define commands for moving through warnings and errors.
command! -bar ALEPrevious :call ale#loclist_jumping#Jump('before', 0)