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

Implement a default prettier formatter? #188

Closed
everdimension opened this issue Aug 9, 2019 · 3 comments
Closed

Implement a default prettier formatter? #188

everdimension opened this issue Aug 9, 2019 · 3 comments

Comments

@everdimension
Copy link

I'm coming from Atom editor, where the expirience of using a prettier plugin was a bit better.
There are two things I wish to have:

  • When neither prettier nor prettier config is found in the project folder of the file you're trying to format, I wish the plugin used its inner prettier installation and default configuration. I do not want to install prettier globally for that

  • I wish to be able to format new (unsaved) files with the prettier plugin, given that I have set the syntax for the file as javascript, typescript, html, css or mdx (or any other syntax supported by prettier)

Thanks! If I can help in any way, please say so, I'd be glad to.

@jonlabelle
Copy link
Owner

Hi @everdimension:

  • When neither prettier nor prettier config is found in the project folder of the file you're trying to format, I wish the plugin used its inner prettier installation and default configuration. I do not want to install prettier globally for that

So I thought about packaging Prettier with the plug-in, but err'd on the side of caution not to bloat the installation. Thought process being that such cases where Prettier isn't already installed (somewhere), would be quite seldom, thus not worth the effort.

  • I wish to be able to format new (unsaved) files with the prettier plugin, given that I have set the syntax for the file as javascript, typescript, html, css or mdx (or any other syntax supported by prettier)

Thanks! If I can help in any way, please say so, I'd be glad to.

This has come up a few times, but will take quite a bit of effort to implement. That said, pull requests are ALWAYS welcome.

@everdimension
Copy link
Author

but will take quite a bit of effort to implement

I don't think I understand. You have access to the view and its contents (just text), you have prettier. What does it matter if the file is "saved" or not?
I'm sure you're speaking from experience, but from a glance this seems like a trivial task. Can you elaborate why it's hard? Does it not fit into sublime text's paradigm in some way?

So I thought about packaging Prettier with the plug-in, but err'd on the side of caution not to bloat the installation. Thought process being that such cases where Prettier isn't already installed (somewhere), would be quite seldom, thus not worth the effort.

I don't think it's fair calling this "bloat". The user experience suffers for sure, but what exactly do you save here?

such cases where Prettier isn't already installed (somewhere), would be quite seldom

I have been using prettier daily almost since it was introduced and I have never installed it globally until yesterday because this plugin wasn't able to format a javascript file I had. That being said, I don't think I even understand the steps of how this plugin resolves prettier installation. So far it seems that it only works with typescript files if I don't have a global prettier installation.


On the other hand, everything I need from the plugin doesn't sound complicated:

  1. Resolve prettier installation for the current file. If nothing is found, use prettier that ships with plugin.
  2. Resolve config for current file. If nothing is found (or the file is not on disk), use default configuration that ships with plugin (can be modified by user).
  3. Format file. Done

Again, I don't want to imply you're doing something wrong: I'm not that familiar yet with plugin development for Sublime Text. But if you could explain in a bit more details the motivation for not including these features it would help me understand how to contribute, or it will maybe make me see that it's not worth the trouble. Thank you.

@lock
Copy link

lock bot commented Oct 7, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants