Do you want to request a feature or report a bug?
Bug
What is the current/expected behavior?
The logic surrounding autoformat_config_present basically only runs once (when the plugin is loaded). It is desirable for that logic to be deferred until the buffer is actually written in at least two cases:
- If you create a
prettier config file in the project after you started the vim instance or
- If you just happened to have started vim in a different directory, then
:cd'ed into the directory where a prettier config file resides (or a subdirectory of such a directory)
The former bug is hopefully straightforward, but I've given more detail for the latter bug below in case it's not clear.
STR:
In .vimrc
let g:prettier#autoformat = 0 " default setting
let g:prettier#autoformat_config_present = 1 " default is 0
Example project structure:
mkdir vim-prettier-pwd-test
mkdir vim-prettier-pwd-test/plugin
echo '{}' > vim-prettier-pwd-test/plugin/.prettierrc
cat > vim-prettier-pwd-test/plugin/index.ts <<'EOF'
/**
* @format
*/
console.log('hello');
EOF
tree -a vim-prettier-pwd-test
vim-prettier-pwd-test
└── plugin
├── .prettierrc
└── index.ts
1 directory, 2 files
Open vim, :cd (or :lcd or :tcd in nvim), open the file and save
cd vim-prettier-pwd-test
nvim
:cd plugin
:e index.ts
:w
Expected
Prettier runs when you save the buffer
Observed
Prettier does not run
What version of vim-prettier are you using - (output of :PrettierVersion) ?
1.0.0-alpha
What version of prettier are you using - (output of :PrettierCliVersion) ?
2.0.4
What is your prettier executable path - (output of :PrettierCliPath) ?
/Users/chris.larose/vim-prettier-pwd-test/plugin/node_modules/.bin/prettier
Did this work in previous versions of vim-prettier and/or prettier ?
Pretty sure the same behavior has been present since the introduction of autoformat_config_present in #212
Do you want to request a feature or report a bug?
Bug
What is the current/expected behavior?
The logic surrounding
autoformat_config_presentbasically only runs once (when the plugin is loaded). It is desirable for that logic to be deferred until the buffer is actually written in at least two cases:prettierconfig file in the project after you started the vim instance or:cd'ed into the directory where a prettier config file resides (or a subdirectory of such a directory)The former bug is hopefully straightforward, but I've given more detail for the latter bug below in case it's not clear.
STR:
In
.vimrcExample project structure:
Open
vim,:cd(or:lcdor:tcdin nvim), open the file and saveExpected
Prettier runs when you save the buffer
Observed
Prettier does not run
What version of
vim-prettierare you using - (output of:PrettierVersion) ?1.0.0-alphaWhat version of
prettierare you using - (output of:PrettierCliVersion) ?2.0.4What is your
prettierexecutable path - (output of:PrettierCliPath) ?Did this work in previous versions of vim-prettier and/or prettier ?
Pretty sure the same behavior has been present since the introduction of
autoformat_config_presentin #212