Comments (5)
I will create an issue on prettier
as well. prettier/prettier#3386
from vim-prettier.
Hi @trungdq88,
Thanks for raising that, the reason why it may seem slower is that the command you are comparing it to is not the same command that vim-prettier
executes over prettier
you can see it in here (https://github.com/prettier/vim-prettier/blob/master/autoload/prettier.vim#L240).
Could you try running the same command on the command line ? intead of your example prettier --write app.js
try:
cat app.js | prettier --print-width 80 --tab-width 2 --use-tabs false --semi true --single-quote true --bracket-spacing false --jsx-bracket-same-line true --trailing-comma all --parser flow --config-precedence prefer-file --stdin-filepath app.js --stdin
I have a feeling what is causing it to be slow will be some of the arguments passed to prettier itself, probably either --stdin-filepath
or --config-precedence
.
Please note you can also test this assumption by calling prettier CLI from vim directly and profiling that like:
:PrettierCli --write app.js
Will close this issue now but please comment in here your findings and if that is something related to vim-prettier
itself I will make sure to work into fixing it. If its realted to prettier
itself I may also be able to contribute a fix back to prettier
.
Once again thank you for reporting this issue and looking forward to know a bit more about your findings!
from vim-prettier.
I have also just tested it locally and confirmed this is prettier
related.
Check this:
mitermayer@primus ~/temp $ time cat app.js | prettier --print-width 80 --tab-width 2 --use-tabs false --semi true --single-quote true --bracket-spacing false --jsx-bracket-same-line true --trailing-comma all --parser flow --config-precedence prefer-file --stdin-filepath app.js --stdin
const a = 1;
real 0m1.150s
user 0m1.055s
sys 0m0.113s
compared to:
mitermayer@primus ~/temp $ time prettier app.js
const a = 1;
real 0m1.081s
user 0m1.014s
sys 0m0.070s
I don't have time right now to dig in on what exactly from that command is causing prettier to behave slower, but if you can find it out I should be able to then work on something prettier
main repo itself to mitigate it
from vim-prettier.
Also worth testing this out with different versions of prettier
as this could also be some performance regressions by prettier
itself creating new features
from vim-prettier.
prettier
reported the task took 44ms. But the actual time prettier app.js
took ~1s. This is might have something to do with the "bootstrap time" of prettier
.
Is it possible to run something like a "daemon" or "prettier server" to "bootstrap" prettier only once?
from vim-prettier.
Related Issues (20)
- feature request to disable automatic mappings set by the plugin
- .eslintrc is ignored
- prettier hang on formatting a bigger file
- MacOS Monterey M1 plugin not loaded
- When endOfLine option set to 'crlf', ^M appear at the end of each line
- Prettier: failed to parse buffer — on mixed HTML/PHP file HOT 1
- Formatting on save stop when saving again
- Deletes comments in Ruby files HOT 3
- The same prettier doesn't work correctly on WSL
- plugin didn't work without installing eslint-config-prettier & eslint-plugin-prettier
- Request: check for filetype javascript (not just the .js and .jsx extensions) HOT 1
- Prettier auto format on Save not working. HOT 1
- Why prettier keeps adding warn messages on top of my document? HOT 16
- Deprecated / Unknown options when using Prettier v3 HOT 3
- Keep show warning after save! HOT 1
- Error while resolving package dependencies HOT 3
- Error on manual trigger
- prettier runs with incorrect prettier configuration HOT 2
- Vim-Prettier is using its own defaults, not the defaults from prettier (in my case, trailingComma)
- `Failed to parse buffers` for Ruby files. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-prettier.