I am trying to configure prettier-eslint
and prettier-standard
as the js formatter with neoformat:
" neoformat should try formatprg where available
let g:neoformat_try_formatprg = 1
augroup vimrc
" if eslint is found
if HasEslint()
"get path of prettier-eslint
let g:prettier_eslint_path = system('PATH=$(npm bin):$PATH && which prettier-eslint')
echom g:prettier_eslint_path
if s:has_eslintrc_path
"get full path to eslintrc if eslintrc file exists
let g:eslintrc_full_path = getcwd() + s:eslintrc_path
echom g:eslintrc_full_path
autocmd FileType javascript set formatprg = g:prettier_eslint_path --filePath g:eslintrc_full_path
elseif s:has_eslintConfig
let g:eslintConfig = system("jq < package.json '.eslintConfig'")
echom g:eslintConfig
autocmd FileType javascript set formatprg = g:prettier_eslint_path --eslintConfig g:eslintConfig
endif
else
" just use prettier-standard
autocmd FileType javascript set formatprg=prettier-standard
endif
autocmd BufWritePre *.js Neoformat
" autocmd BufWritePre,TextChanged,InsertLeave *.js Neoformat
augroup end
When opening a js
file, it gives me an error saying that it could not find g:prettier_eslint_path
.
How can I configure vim to use the local version of prettier-eslint
and pass the appropriate options to it. It seems to use the default settings if no options are provided.