-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate fixers on save from enabled fixers. #1930
Comments
For now, you can also use |
I ran into this today as well. As a first step, I have something like this: nnoremap F :ALEFixToggle<CR>
function! ALEFixToggle()
if g:ale_fix_on_save ==# 1
let g:ale_fix_on_save = 0
echo "ALEFix disabled"
else
let g:ale_fix_on_save = 1
echo "ALEFix enabled"
endif
endfunction
command! ALEFixToggle call ALEFixToggle() And in a custom " Only enable rustfmt if a `rustfmt.toml` file exists.
let g:ale_fix_on_save = filereadable("rustfmt.toml") This makes it easy to only use This has a dependecy on something like vim-rooter. |
Having thought about this, it will be better to add an option to ignore fixers on save, rather than select them. Consider the following case where you select fixers to run. let g:ale_fixers = {'foo': ['a', 'b'], 'bar': ['c']}
let g:ale_fixers_on_save = {'foo': ['b']}
" Say your filetype is `foo.bar`.
" Whether you want ['b', 'c'] or only ['b'] is ambiguous. Consider it again where you ignore them. let g:ale_fixers = {'foo': ['a', 'b'], 'bar': ['c']}
let g:ale_fix_on_save_ignore = {'foo': ['a']}
" No ambiguity, the result is ['b', 'c']
" Lists would also work for applying to all filetypes.
let g:ale_fix_on_save_ignore = ['a'] As always, Lists in ftplugin files are preferred, and make life simpler. let b:ale_fixers = ['a', 'b', 'c']
let b:ale_fix_on_save_ignore = ['b'] I have implemented this, pending some tests. |
That option has been added now. |
Thanks, that’s great! |
I'd like to be able to have a set of fixers that run on save that is separate from the fixers that run with
:ALEFix
.For example, I universally want to have the
remove_trailing_lines
andtrim_whitespace
fixers to run when I save a file, but I do not always want to run therustfmt
fixer when I save (some projects don't use it and I don't want to reformat lots of code that isn't my own).This would enable me to always have trailing lines removed and whitespace trimmed without needing to remember to do that, but gives me the option of triggering
rustfmt
manually through ALE on my own projects with my binding to:ALEFix
.The text was updated successfully, but these errors were encountered: