Comments (10)
Makes sense I guess. As @CiGit laid out in #33 there could be a prioritization order a long the lines of.
- Use local version
- Use global version
- Use package version
As far as I can tell this is what is going on here https://github.com/Microsoft/vscode-eslint/blob/master/eslint-server/src/server.ts#L257
from prettier-vscode.
ref #33
from prettier-vscode.
Hey any update on this one @esbenp? I was just bitten by this after updating to 0.18.0.
from prettier-vscode.
Honestly, February is pretty booked with work, so wont have time until at the end. Any PRs are welcome though..
from prettier-vscode.
I'll certainly try to work on this in these upcoming days.
@esbenp Is it okay for you if there is a new configuration option to define the global installation folder(/usr/lib/node_modules/prettier for example) or would you prefer relying on PATH to find the global executable cli and then mess around to find the lib.
I see the later more difficult to implement correctly. It depends on OS/package manager (npm, yarn, ...) combination
from prettier-vscode.
Looking at https://github.com/Microsoft/vscode-eslint/blob/master/eslint-server/src/server.ts#L349 it seems they way they do it is to use Files
of vscode-languageserver-node
. You can see the method here https://github.com/Microsoft/vscode-languageserver-node/blob/8291f55041ea023c4acefa73d8f25f5384aa6426/server/src/files.ts#L178
Maybe just copy-paste resolveGlobalNodePath
into our repo and use it to resolve the global node path in case no local is found? What do you think?
from prettier-vscode.
resolveGlobalNodePath
, like requireg
, are based on npm config get prefix
which is only relevant to npm.
In prettier's readme, installation is first shown with yarn global add prettier
.
But I get it, you prefer no additional config 😉 and I agree with that. I will just need to investigate some more.
from prettier-vscode.
Ah yeah I get what you mean now. Well, maybe there is nothing wrong with adding a path config and set it to null
as default. If null
, run the 1. local -> 2. npm global -> plugin. If not null, use that if executable is found or fall back to previous priority
from prettier-vscode.
Sorry if I was unclear.
If I get your idea correctly:
- try local
- try if(path) path resolve
- try npm global prefix
- bundled
Seems easy to implement but I find this weird as a user.
I've been thinking to alternatives:
- Don't try to resolve any global install (there is currently no issue about a global resolution) and update this extension quickly/often enough. Updating it is required anyway when there is an API/config change.
- Provide a command to update the bundled prettier
npm i prettier@latest
then reload vscode. - Spawn a prettier cli (which is found on the PATH) as a child process. (client / server)
from prettier-vscode.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from prettier-vscode.
Related Issues (20)
- Editor scrolls to bottom when format large file using prettier HOT 2
- Extension only looks for .gitignore or .prettierignore when using Prettier v3, does not allow both HOT 1
- Use LanguageStatusItem API for the status bar item HOT 1
- prettier bug in Vue
- Prettier extension deletes line of code after pasting
- icons
- Prettier doesn't appear in the list of formatters HOT 5
- Installed Prettier extension does not format and gives following error: Cannot find module 'prettier' HOT 1
- `prettier-vscode` doesn't respond to changes in `prettier.config.mjs` until the workspace reloads HOT 4
- Cannot use any prettier plugins with `yarn 4 + PnP`
- Do not put css comments on new line HOT 1
- I have done all kinds of things but my prettier does not format on save. HOT 1
- I need to completely uninstall prettier an reinstall it. HOT 1
- Title: Feature Request: Improved Support for C Language in Prettier Extension
- Prettier does not format in multi-folder repositories whilst using the .code-workspace config. HOT 1
- Use NODE_COMPILE_CACHE when detecting node v22+
- Extension causes high cpu load
- experimentalTernaries not respected using prettier-vscode plugin HOT 1
- When I set Prettier: Single Attribute Per Line, the css style in the <style> tag of the vue file was invalid.
- in bash file a piece of code is treated like a comment
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 prettier-vscode.