Improve file blacklisting to make Unite.vim not fuck up.

This commit is contained in:
w0rp 2016-10-31 14:47:08 +00:00
parent cb410927d1
commit 614a30a508
4 changed files with 31 additions and 14 deletions

View File

@ -5,6 +5,11 @@
let s:lint_timer = -1 let s:lint_timer = -1
function! ale#Queue(delay) abort function! ale#Queue(delay) abort
" Do nothing for blacklisted files.
if index(g:ale_filetype_blacklist, &filetype) >= 0
return
endif
if s:lint_timer != -1 if s:lint_timer != -1
call timer_stop(s:lint_timer) call timer_stop(s:lint_timer)
let s:lint_timer = -1 let s:lint_timer = -1
@ -24,6 +29,11 @@ function! ale#Queue(delay) abort
endfunction endfunction
function! ale#Lint(...) abort function! ale#Lint(...) abort
" Do nothing for blacklisted files.
if index(g:ale_filetype_blacklist, &filetype) >= 0
return
endif
let l:buffer = bufnr('%') let l:buffer = bufnr('%')
let l:linters = ale#linter#Get(&filetype) let l:linters = ale#linter#Get(&filetype)

View File

@ -73,6 +73,11 @@ let s:cursor_timer = -1
let s:last_pos = [0, 0, 0] let s:last_pos = [0, 0, 0]
function! ale#cursor#EchoCursorWarningWithDelay() abort function! ale#cursor#EchoCursorWarningWithDelay() abort
" Do nothing for blacklisted files.
if index(g:ale_filetype_blacklist, &filetype) >= 0
return
endif
if s:cursor_timer != -1 if s:cursor_timer != -1
call timer_stop(s:cursor_timer) call timer_stop(s:cursor_timer)
let s:cursor_timer = -1 let s:cursor_timer = -1

View File

@ -33,15 +33,6 @@ let g:ale_buffer_info = {}
" filetypes which can cause issues. " filetypes which can cause issues.
let g:ale_filetype_blacklist = ['nerdtree', 'unite'] let g:ale_filetype_blacklist = ['nerdtree', 'unite']
" This function lets you define autocmd commands which blacklist particular
" filetypes.
function! ALEAutoCMD(events, function_call)
execute 'autocmd '
\ . a:events
\ ' * if index(g:ale_filetype_blacklist, &filetype) < 0 | call '
\ . a:function_call
endfunction
" This Dictionary configures which linters are enabled for which languages. " This Dictionary configures which linters are enabled for which languages.
let g:ale_linters = get(g:, 'ale_linters', {}) let g:ale_linters = get(g:, 'ale_linters', {})
@ -59,7 +50,7 @@ let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 1)
if g:ale_lint_on_text_changed if g:ale_lint_on_text_changed
augroup ALERunOnTextChangedGroup augroup ALERunOnTextChangedGroup
autocmd! autocmd!
call ALEAutoCMD('TextChanged,TextChangedI', 'ale#Queue(g:ale_lint_delay)') autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay)
augroup END augroup END
endif endif
@ -68,7 +59,7 @@ let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1)
if g:ale_lint_on_enter if g:ale_lint_on_enter
augroup ALERunOnEnterGroup augroup ALERunOnEnterGroup
autocmd! autocmd!
call ALEAutoCMD('BufEnter,BufRead', 'ale#Queue(300)') autocmd BufEnter,BufRead * call ale#Queue(300)
augroup END augroup END
endif endif
@ -77,7 +68,7 @@ let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 0)
if g:ale_lint_on_save if g:ale_lint_on_save
augroup ALERunOnSaveGroup augroup ALERunOnSaveGroup
autocmd! autocmd!
call ALEAutoCMD('BufWrite', 'ale#Queue(0)') autocmd BufWrite * call ale#Queue(0)
augroup END augroup END
endif endif
@ -114,7 +105,7 @@ let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
if g:ale_echo_cursor if g:ale_echo_cursor
augroup ALECursorGroup augroup ALECursorGroup
autocmd! autocmd!
call ALEAutoCMD('CursorMoved,CursorHold', 'ale#cursor#EchoCursorWarningWithDelay()') autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay()
augroup END augroup END
endif endif
@ -148,7 +139,7 @@ nnoremap <silent> <Plug>(ale_next_wrap) :ALENextWrap<Return>
augroup ALECleanupGroup augroup ALECleanupGroup
autocmd! autocmd!
" Clean up buffers automatically when they are unloaded. " Clean up buffers automatically when they are unloaded.
call ALEAutoCMD('BufUnload', "ale#cleanup#Buffer(expand('<abuf>'))") autocmd BufUnload * call ale#cleanup#Buffer(expand('<abuf>'))
augroup END augroup END
" Backwards Compatibility " Backwards Compatibility

View File

@ -0,0 +1,11 @@
Given unite (A Unite.vim file):
anything
After:
let g:ale_buffer_info = {}
Execute(Running ALE on a blacklisted file shouldn't change anything):
call ale#Lint()
call ale#engine#WaitForJobs(2000)
AssertEqual {}, g:ale_buffer_info