neoformat icon indicating copy to clipboard operation
neoformat copied to clipboard

Neoformat ignoring enabled setting

Open shinzui opened this issue 6 years ago • 2 comments

Neoformat seems to ignore my enabled formatters on occasion and decides to run prettier instead. I am wondering what I can do to prevent that since it ruins my flow every time it happens. This mostly affectterraform and ocaml files. My config is below.

augroup fmt
  autocmd!
  autocmd BufWritePre * undojoin | Neoformat
augroup END
autocmd FileType javascript set formatprg=prettier\ --stdin\ --parser\ flow\ --single-quote\ --print-width\ 100\ --no-semi\ --trailing-comma\ es5
autocmd FileType javascript.jsx set formatprg=prettier\ --stdin\ --parser\ flow\ --single-quote\ --print-width\ 101\ --no-semi\ --trailing-comma\ es5
autocmd FileType javascript JsPreTmpl html
autocmd FileType graphql set formatprg=prettier
autocmd FileType json set formatprg=prettier
autocmd FileType yaml set formatprg=pyaml
autocmd FileType toml set formatprg=
autocmd FileType markdown set formatprg=prettier\ --parser\ markdown
let g:neoformat_try_formatprg = 1
let g:neoformat_enabled_javascript = [ 'prettier' ]
let g:neoformat_enabled_terraform = [ 'terraform' ]
let g:neoformat_enabled_handlebars = []
let g:neoformat_enabled_reason = [ 'refmt' ]
let g:neoformat_enabled_ocaml = ['ocamlformat']
let g:neoformat_enabled_html = []

Here is the relevant section from the logs when I save an OCaml file. Shouldn't Neoformatonly run ocamlformat since I have let g:neoformat_enabled_ocaml = ['ocamlformat'] configured?

Neoformat: prettier --parser markdown
Neoformat: using stdin

set ft? returns filetype=ocaml

shinzui avatar Jul 22 '18 14:07 shinzui

I am pretty sure that a formatprg will override any other setup for that filetype.

Not sure why the markdown formatprg is being used for other filetypes.

If you remove the let g:neoformat_try_formatprg = 1 what happens?

sbdchd avatar Aug 11 '18 15:08 sbdchd

I can't reproduce when I remove let g:neoformat_try_formatprg

shinzui avatar Sep 16 '18 14:09 shinzui