Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do we need to install "prettier-java" seperately when we already install prettier? #317

Closed
PranavBhattarai opened this issue Dec 6, 2019 · 16 comments

Comments

@PranavBhattarai
Copy link

Because the original prettier doesn't mention this as u can see in this screenshot.
Screenshot from 2019-12-06 10-37-36

So wondering if installing "prettier" will also support java files/program, right?

(noob)

@PranavBhattarai PranavBhattarai changed the title Dunno where to ask so I am asking here: Do we need to install "prettier-java" seperately when we install already install prettier? Dunno where to ask so I am asking here: Do we need to install "prettier-java" seperately when we already install prettier? Dec 6, 2019
@clementdessoude
Copy link
Contributor

Hi @PranavBhattarai !

As it is a community plugin, you have to install the prettier and prettier-plugin-java packages to make it work. Let me know if you have issues installing them :)

@clementdessoude clementdessoude changed the title Dunno where to ask so I am asking here: Do we need to install "prettier-java" seperately when we already install prettier? Do we need to install "prettier-java" seperately when we already install prettier? Dec 6, 2019
@PranavBhattarai
Copy link
Author

@clementdessoude Do I have to install npm or yarn inorder to have this?
I wonder why it is not integrated with the main extension? Why it is separated like this?
Is there any benefit doing this!

@bd82
Copy link
Contributor

bd82 commented Dec 6, 2019

Do I have to install npm or yarn inorder to have this?
I wonder why it is not integrated with the main extension? Why it is separated like this?
Is there any benefit doing this!

When you say "main extension" do you mean the main npm package "prettier" or some IDE extension?

@PranavBhattarai
Copy link
Author

@bd82 When I say the main extension, I mean "Prettier extension" when we (everyone's) installs.

Why prettier for java functionality is sperated like this?

@clementdessoude
Copy link
Contributor

clementdessoude commented Dec 6, 2019

Prettier Java is a community plug-in, so we are not integrated in the main Prettier library. We are not in the same project as it would be a burden for the Prettier team to maintain this, so we offered to develop this on our own.

For the moment, to install prettier-plugin-java, you have to install it with npm or yarn (either locally or globally). You can also check this maven plug-in developed by @jhaber if you use maven. The docs are not exhaustive, but it should be explained in the Readme

@PranavBhattarai
Copy link
Author

@clementdessoude What if I made feature-request about java support in the Prettier repo?
Saying the word 'burden' is one way to shut down development. Everything is built has to go through certain burden and then it becomes awesome product.

Installing another unknown package manager like yarn or npm, just to use prettier-java is the representation underdevelopment.

I might sound bad, but don't take it in the wrong way. I'm just learning how things are. Sorry in advance

@jhaber
Copy link
Contributor

jhaber commented Dec 6, 2019

There is some documentation on prettier plugins here:
https://prettier.io/docs/en/plugins.html

In particular:

The core prettier package contains JavaScript and other web-focused languages built in. For additional languages you'll need to install a plugin.

There are even "official" plugins that live in the Prettier org on GitHub but are still kept in separate repositories and must be installed separately:
https://prettier.io/docs/en/plugins.html#official-plugins

I think if you made such a feature request on Prettier repo they would just point you at this documentation. It has a plugin system precisely because they want prettier to be extensible, not monolithic.

@jhaber
Copy link
Contributor

jhaber commented Dec 6, 2019

I'm also not sure what you mean by this:

Installing another unknown package manager like yarn or npm, just to use prettier-java is the representation underdevelopment.

Installing prettier itself requires either yarn or npm:
https://prettier.io/docs/en/install.html

@bd82
Copy link
Contributor

bd82 commented Dec 6, 2019

@bd82 When I say the main extension, I mean "Prettier extension" when we (everyone's) installs.

I still don't fully understand. I am not sure your terminology is accurate...

  • How do you currently install and use prettier?

I see multiple separate issues here:

GitHub Organization

Would moving this project to the prettier organization help consumption/usage/discovery in any manner?

Inclusion as part of the main prettier package.

Should this package be included as part of the root prettier **repository** / **package**?

  • This is not something that can be decided only by personas in the jhipster org...
  • According to the docs this plugin does not seem to fit the core prettier package scope.

The core prettier package contains JavaScript and other web-focused languages built in. For additional languages you'll need to install a plugin.

Providing a standalone executable for prettier-java

Many of the potential users of prettier-java may not have node.js/npm/yarn installed.
Perhaps a delivery channel as a standalone executable could be investigated.

Providing prettier-java as a maven / gradle plugin

Same concern as above to make consumption easy for potential users who do not have
node.js / npm / a package.json in their project.

@PranavBhattarai
Copy link
Author

PranavBhattarai commented Dec 7, 2019

@jhaber Prettier can be install by going on Extension > Search "Prettier" > Select "Enable".

I don't see yarn or npm commands, do I?

@bd82
Copy link
Contributor

bd82 commented Dec 7, 2019

Prettier can be install by going on Extension > Search "Prettier" > Select "Enable".

Where can it be done like this?, in which IDE / Editor? (I see you are talking of VSCode now...)

I believe you are confusing IDE / Editor extensions and the core prettier package and plugins packages...

The VSCode Prettier extension does seem to support plugins:

However it assumes a local version of pettier and a local package.json (npm/node project).
Perhaps different plugin support mechanisms in IDE extensions could be investigated.

This is similar to some of the topics I described above (standalone executable / JVM ecosystem build tools integration).

@bd82
Copy link
Contributor

bd82 commented Dec 7, 2019

Because the original prettier doesn't mention this as u can see in this screenshot.

So the original prettier extension does mention plugins

And there does not seem to be a solution to avoid npm/node/package.json dependency.
See:

I think that prettier-java has a real need to de-couple itself from the node/npm eco-system. But I am not sure that such de-coupling should happen via IDE extensions (at least initially). It seems to me a stand-alone executable should be the first step in achieving said "de-coupling" for multiple scenarios (Build-Tools/Local Dev Env/IDE Ext/...)

@PranavBhattarai
Copy link
Author

PranavBhattarai commented Dec 7, 2019

@bd82
Final question:
How can I install this plugin inside VScode? Don't i need to install npm or yarn first?

@bd82
Copy link
Contributor

bd82 commented Dec 7, 2019

How can I install this plugin inside VScode? Don't i need to install npm or yarn first?

@PranavBhattarai I think you do need npm/yarn.

I do not use VSCode much, but if I understand the instructions correctly:

You need a package.json with a dependency to both prettier and prettier-plugin-java.
So this means (afaik) that you need npm/node/yarn/ too...

I will mention again that this repository has absolutely nothing to do with VSCode extensions/plugins. This repository artifacts are published as npm packages.
For the prettier VSCode Extension and its plugin loading systems you need to see the relevant project: https://github.com/prettier/prettier-vscode

Anyhow unrelated to VSCode we should consider a standalone binary artifact because many in the JVM ecosystem do not have node/npm...

@MxD-js
Copy link

MxD-js commented May 9, 2021

How does this integrate into vscode, other than using the terminal built into vscode? So means I need to have node and npm installed on a dev system that I will not touch Js, only Java.

How does this project compare to https://marketplace.visualstudio.com/items?itemName=mwpb.java-prettier-formatter

@bd82
Copy link
Contributor

bd82 commented May 11, 2021

I think you can integrate with VSCode Prettier extension (see plugins section).

This project was created because of a need to format generated Java Code in a pure JS env, without needing Java.
If you need a pure Java CLI Formatter perhaps there are other CLI tools, I am not familiar with that ecosystem...

BTW I found some reference to a binary artifact release, but I can't seem to actually find the binary anywhere :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants