Note: this is a neovim question, not stock vim

I have both rbprettier and prettier with the ruby plugin installed on my system. If I pipe a Ruby file into rbprettier, or if I pipe it into prettier --parser ruby, I get back a properly formatted version of the file.

I have ALE configured to format on save, and when ALE pipes the file into prettier, it always does so with --parser babel, which triggers fatal errors.

This is my ALE fixer configuration:

let g:ale_fixers = {
\   '*': ['remove_trailing_lines', 'trim_whitespace'],
\   'javascript': ['prettier', 'eslint'],
\   'typescript': ['prettier', 'eslint'],
\   'ruby': ['prettier'],
\   'rust': ['rustfmt'],
let g:ale_fix_on_save = 1

How can I reconfigure ALE to either call rbprettier directly for Ruby files, or to add the --parser ruby option instead of --parser javascript when I'm working in a Ruby file?

1 Answer 1


ALE doesn't seem to support prettier for Ruby in its default configuration.

Though it offers enough hooks for you to use a different executable (such as rbprettier) or to pass it additional arguments (such as --parser ruby).

You can override these with buffer-local variables b:ale_javascript_prettier_executable and b:ale_javascript_prettier_options. See autoload/ale/fixers/prettier.vim in the ALE source tree for the code that defines and uses these variables.

You can try something like the following:

augroup ale_ruby
  au FileType ruby let b:ale_javascript_prettier_executable = 'rbprettier'
  " Or:
  au FileType ruby let b:ale_javascript_prettier_options = '--parser ruby'
augroup END

Note you only need one or the other, not both!

Another alternative is to consider one of the fixers for Ruby supported out-of-the-box. You can find the registry in autoload/ale/fix/registry.vim in the source tree, if you search for "ruby" you will find it supports rubocop, rufo, sorbet and standardrb.

And one final approach is that you can write your own custom Vim function for a fixer, in which you could invoke prettier however you like. See :help ale-fix for some more details on that.

  • 1
    Did not try the first form, but did try the second form with great success! Commented Aug 5, 2019 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.