I have the following line of code:
autocmd FileType javascript execute "setlocal formatprg=".g:prettier_eslint_path2."\\ --eslint-config-path" . g:eslintrc_full_path ."\\"
I can see this when I start vim in the directory which has .eslintrc
:
ESLINTRC PATH
.eslintrc
Prettier ESLINT PATH
/Users/localuser/lendi/lendi-app/node_modules/.bin/prettier-eslint^@
/Users/localuser/lendi/lendi-app/node_modules/.bin/prettier-eslint
Has ESLINTRC
/Users/localuser/lendi/lendi-app/.eslintrc
--- Auto-Commands ---
Press ENTER or type command to continue
I have the g:eslintrc_full_path
logged out correctly, how do I pass it from the variable to formatprg correctly.
If I remove the args, I get an empty output as the result of the file.
If I remove the \\
it informs that it is valid to do so.
I dont understand how to pass arguments to the cli script when using a variable. I did not find any examples of string interpolation when reading through http://learnvimscriptthehardway.stevelosh.com/chapters/26.html
Also, the following code also causes a problem:
autocmd FileType javascript execute "setlocal formatprg=".g:prettier_eslint_path2."\\ --eslint-config-path\\ ".g:eslintrc_full_path
and deletes the entire file. I have tried:
autocmd FileType javascript execute "setlocal formatprg=".g:prettier_eslint_path2."\\ --eslint-config-path\\ ".g:eslintrc_full_path
but it deletes the contents of the file as well.
I have tried it with only --stdin
like this but it fails and converts everything to double quotes:
autocmd FileType javascript execute "setlocal formatprg=".g:prettier_eslint_path2."\\ --stdin"
I have tried adding in the single quote as an argument here but it still converts everything to double-quotes.
autocmd FileType javascript let &l:formatprg= g:prettier_eslint_path2."\\ --single-quote\\ --eslint-config-path\\ ". g:eslintrc_full_path
Also, logging &l:formatprg
does not work:
autocmd FileType javascript let &l:formatprg = g:prettier_eslint_path2.' --single-quote --eslint-config-path '. g:eslintrc_full_path
echom &l:formatprg
I tried checking the messages:
and it shows:
/Users/localuser/lendi/lendi-app/node_modules/.bin/prettier-eslint --single-quote --write --eslint-config-path /Users/localuser/lendi/lendi-app/.eslintrc
which should work. How does neoformat pass the file to the cli script.
How do I solve this problem?
I have also created a issue on neoformat
for the same:
'formatprg'
. For help using Neoformat, I suggest reading:help neoformat.txt