## Information
VIM version
NVIM v0.2.2
Build Type: Release
Operating System: macOS 10.13.3 (17D47)
## What went wrong
I ran the ~~:ALEDisable command so ALE wouldn't fix the file on save, checked if g:ale_enabled
~~was falsy and saved the file, but the fixers still ran.
## Reproducing the bug
Steps for repeating the bug:
1. Open a file that fixers would be applied to
1. Set g:ale_fix_on_save to 1 if not yet set
1. Run :ALEDisable
1. Save the file
### Expected
No fixers applied to the file when saved
### Actual Result
Prettier is still applied to the current file.
### Caveats
Manually setting g:ale_fix_on_save to 0 make ALE behave as expected.
So yeah, I guess I missed #1353 when looking through the issues and this is the expected behavior. Maybe add this info on the README to make it clear that :ALEDisable does not affect fixers?
If anyone comes here with the same problem, here's how I've worked my way around this:
I created a few commands in the file ~/.vim/plugin/commands.vim:
command! ALEDisableFixers let g:ale_fix_on_save=0
command! ALEEnableFixers let g:ale_fix_on_save=1
command! ALEDisableFixersBuffer let b:ale_fix_on_save=0
command! ALEEnableFixersBuffer let b:ale_fix_on_save=0
command! ALEToggleFixers call functions#fckALEToggle('global')
command! ALEToggleFixersBuffer call functions#fckALEToggle('buffer')
And on my ~/.vim/autoload/functions.vim I've added the toggle function:
function! functions#fckALEToggle(...)
let s:fckALEStatus = {}
let s:fckALEStatus['global'] = get(g:, 'ale_fix_on_save', 0)
let s:fckALEStatus['buffer'] = get(b:, 'ale_fix_on_save', s:fckALEStatus['global'])
let s:fckCurrentScope = get(a:, 1, 'global')
if (s:fckALEStatus[s:fckCurrentScope] == 1)
let s:fckALEStatus[s:fckCurrentScope]=0
else
let s:fckALEStatus[s:fckCurrentScope]=1
endif
let g:ale_fix_on_save=s:fckALEStatus['global']
let b:ale_fix_on_save=s:fckALEStatus['buffer']
endfunction
@w0rp do you mind if I make a pull-request to add these commands to the plugin itself? Or do you prefer to leave this to be solved on a per-user basis?
The commands don't need to be in the plugin, as they'd just do the same as using let.
My 2-cent: ALEDisable should switch everything off. I was caught quite off-guard when some subtle fixers were active despite by asking ALE to step down.
No. The command has a very different purpose, and predates fixing files.
Most helpful comment
If anyone comes here with the same problem, here's how I've worked my way around this:
I created a few commands in the file
~/.vim/plugin/commands.vim:And on my
~/.vim/autoload/functions.vimI've added the toggle function: