#1930 - Add ale_fix_on_save_ignore for disabling some fixers on save
This commit is contained in:
parent
3a010f68b8
commit
24d277384c
@ -1,3 +1,5 @@
|
||||
call ale#Set('fix_on_save_ignore', {})
|
||||
|
||||
" Apply fixes queued up for buffers which may be hidden.
|
||||
" Vim doesn't let you modify hidden buffers.
|
||||
function! ale#fix#ApplyQueuedFixes() abort
|
||||
@ -265,7 +267,21 @@ function! s:AddSubCallbacks(full_list, callbacks) abort
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:GetCallbacks(buffer, fixers) abort
|
||||
function! s:IgnoreFixers(callback_list, filetype, config) abort
|
||||
if type(a:config) is v:t_list
|
||||
let l:ignore_list = a:config
|
||||
endif
|
||||
|
||||
let l:ignore_list = []
|
||||
|
||||
for l:part in split(a:filetype , '\.')
|
||||
call extend(l:ignore_list, get(a:config, l:part, []))
|
||||
endfor
|
||||
|
||||
call filter(a:callback_list, 'index(l:ignore_list, v:val) < 0')
|
||||
endfunction
|
||||
|
||||
function! s:GetCallbacks(buffer, fixing_flag, fixers) abort
|
||||
if len(a:fixers)
|
||||
let l:callback_list = a:fixers
|
||||
elseif type(get(b:, 'ale_fixers')) is v:t_list
|
||||
@ -290,8 +306,12 @@ function! s:GetCallbacks(buffer, fixers) abort
|
||||
endif
|
||||
endif
|
||||
|
||||
if empty(l:callback_list)
|
||||
return []
|
||||
if a:fixing_flag is# 'save_file'
|
||||
let l:config = ale#Var(a:buffer, 'fix_on_save_ignore')
|
||||
|
||||
if !empty(l:config)
|
||||
call s:IgnoreFixers(l:callback_list, &filetype, l:config)
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:corrected_list = []
|
||||
@ -339,7 +359,7 @@ function! ale#fix#Fix(buffer, fixing_flag, ...) abort
|
||||
endif
|
||||
|
||||
try
|
||||
let l:callback_list = s:GetCallbacks(a:buffer, a:000)
|
||||
let l:callback_list = s:GetCallbacks(a:buffer, a:fixing_flag, a:000)
|
||||
catch /E700\|BADNAME/
|
||||
let l:function_name = join(split(split(v:exception, ':')[3]))
|
||||
let l:echo_message = printf(
|
||||
|
Loading…
Reference in New Issue
Block a user