GithubHelp home page GithubHelp logo

Comments (10)

esbenp avatar esbenp commented on June 5, 2024 1

Makes sense I guess. As @CiGit laid out in #33 there could be a prioritization order a long the lines of.

  1. Use local version
  2. Use global version
  3. 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.

CiGit avatar CiGit commented on June 5, 2024

ref #33

from prettier-vscode.

dburles avatar dburles commented on June 5, 2024

Hey any update on this one @esbenp? I was just bitten by this after updating to 0.18.0.

from prettier-vscode.

esbenp avatar esbenp commented on June 5, 2024

Honestly, February is pretty booked with work, so wont have time until at the end. Any PRs are welcome though..

from prettier-vscode.

CiGit avatar CiGit commented on June 5, 2024

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.

esbenp avatar esbenp commented on June 5, 2024

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.

CiGit avatar CiGit commented on June 5, 2024

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.

esbenp avatar esbenp commented on June 5, 2024

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.

CiGit avatar CiGit commented on June 5, 2024

Sorry if I was unclear.
If I get your idea correctly:

  1. try local
  2. try if(path) path resolve
  3. try npm global prefix
  4. 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.

github-actions avatar github-actions commented on June 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.