vim-autoformat and scalafmt not working

394 Views Asked by At

I am using the https://github.com/Chiel92/vim-autoformat plugin with scalafmt, and have the following in my .vimrc:

" scalafmt settings
let g:formatdef_scalafmt = "'scalafmt --stdin'"
let g:formatters_scala = ['scalafmt']

noremap <localleader>f :Autoformat<CR>

let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0

I have verified that scalafmt is working when I call it from outside vim. There are no error messages displayed, but the buffer does not get updated.

Running :CurrentFormatter results in: Selected formatter: scalafmt

Is there something missing from my configuration?

1

There are 1 best solutions below

0
On

just to make the answer complete,

let g:formatdef_scalafmt = '"scalafmt --stdin 2>/dev/null"'
let g:formatters_scala = ['scalafmt']

as suggested in Issues using vim-autoformat with scalafmt