From 0cd8e8630b69613df3a2a65fdd830364de157129 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 12 Apr 2018 20:31:33 +0100 Subject: #1497 Tolerate important ALE variables being undefined for some reason when viewing buffers like git commits --- autoload/ale.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'autoload/ale.vim') diff --git a/autoload/ale.vim b/autoload/ale.vim index f6c06cf1..5c4a0f55 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -33,6 +33,10 @@ endfunction " Return 1 if a file is too large for ALE to handle. function! ale#FileTooLarge() abort + if !exists('g:ale_maximum_file_size') + return 0 + endif + let l:max = ale#Var(bufnr(''), 'maximum_file_size') return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0 @@ -46,13 +50,18 @@ function! ale#ShouldDoNothing(buffer) abort " The checks are split into separate if statements to make it possible to " profile each check individually with Vim's profiling tools. + " Do nothing if ALE is disabled. + if !getbufvar(a:buffer, 'ale_enabled', get(g:, 'ale_enabled', 0)) + return 1 + endif + " Don't perform any checks when newer NeoVim versions are exiting. if get(v:, 'exiting', v:null) isnot v:null return 1 endif " Do nothing for blacklisted files - if index(g:ale_filetype_blacklist, getbufvar(a:buffer, '&filetype')) >= 0 + if index(get(g:, 'ale_filetype_blacklist', []), getbufvar(a:buffer, '&filetype')) >= 0 return 1 endif @@ -72,11 +81,6 @@ function! ale#ShouldDoNothing(buffer) abort return 1 endif - " Do nothing if ALE is disabled. - if !ale#Var(a:buffer, 'enabled') - return 1 - endif - " Do nothing if the file is too large. if ale#FileTooLarge() return 1 -- cgit v1.2.3