The Wayback Machine - http://web.archive.org/web/20201114044729/https://github.com/prettier/prettier-atom/issues/391
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

Support Atom IDE's built-in code formatting #391

Open
wbinnssmith opened this issue Mar 13, 2018 · 13 comments
Open

Support Atom IDE's built-in code formatting #391

wbinnssmith opened this issue Mar 13, 2018 · 13 comments

Comments

@wbinnssmith
Copy link

@wbinnssmith wbinnssmith commented Mar 13, 2018

Atom IDE supports code formatting and exposes a similar api via the atom services code-format.file, code-format.onSave, and others. It implements similar logic as in prettier-atom for preserving cursor position, etc.

Atom IDE users expect to use cmd-shift-c to format code of all types, not just those supported by Prettier.

I'd be happy to help with this implementation.

cc @hansonw @vjeux

@olsonpm
Copy link
Contributor

@olsonpm olsonpm commented Mar 13, 2018

i'm confused at what you're proposing. It doesn't make sense to me to couple this plugin with atom ide, but if there's something this plugin can do to make it easier for atom-ide to consume it then that would make sense to me.

@wbinnssmith
Copy link
Author

@wbinnssmith wbinnssmith commented Mar 13, 2018

Yep, all that's needed is providing an Atom service or two the same way the above JSON formatter does. The service boundary keeps things neatly decoupled.

@olsonpm
Copy link
Contributor

@olsonpm olsonpm commented Mar 13, 2018

I see - thanks for the links. I didn't know atom had a service api that you could declare in the package.json like that. Seems pretty cool. I'm a new collaborator and wouldn't be the one to okay something like this since it does take on extra maintenance, but it's got my 👍

@SavePointSam
Copy link
Collaborator

@SavePointSam SavePointSam commented Mar 13, 2018

Is there prior art with there being extension plugins for Atom IDE, or is it expected that packages expose hooks for Atom IDE?

I'm hesitant to add more complexity to support a non-standard Atom work environment. As much as I love what Atom IDE is doing (I presently use Nuclide), I'm not convinced it would be our responsibility to provide support. Can you provided non-Nuclide examples (since Atom IDE was born out of Nuclide)?

@olsonpm
Copy link
Contributor

@olsonpm olsonpm commented Mar 13, 2018

my understanding is that packages expose services via atom's service api. It just so happens that atom-ide is the one defining and reading from those services. We would only be importing atom-ide if we wnted to type check our service structure.

without implementing it's hard to know exactly the complexity added, but it didn't seem much. However it would be supporting a new endpoint into the plugin so i think the maintenance is a valid concern.

@SavePointSam
Copy link
Collaborator

@SavePointSam SavePointSam commented Mar 13, 2018

Looking at the provided documentation it seems almost too easy, which is why I'm skeptical. Haha. What are your thoughts on this @robwise?

@robwise
Copy link
Collaborator

@robwise robwise commented Mar 16, 2018

I'd be fine with doing this, I use atom-ide so at least one of us would be already set up to mess with it and test bugs. My only question is if we expose this to atom-ide so that it can format on save, then do we need to turn the normal format on save?

@olsonpm
Copy link
Contributor

@olsonpm olsonpm commented Mar 16, 2018

Not sure what you mean by "the normal format on save".

Anywhoo @wbinnssmith seems you're good to start on a PR when you feel it. You can ping me if you have questions about the code.

@robwise
Copy link
Collaborator

@robwise robwise commented Mar 17, 2018

This change would expose a new, other format-on-save functionality that can be turned on in atom-ide's settings. This would be in addition to the existing format-on-save functionality we've always had in this package, which I'm referring to as the "normal" format-on-save.

Is it going to double format-on-save? When I save a file, atom-ide will detect it and invoke format-on-save in all of the services offering that functionality which, if we implement this, would include us. So prettier gets invoked from atom-ide. However, we're also watching for a file being saved directly ourselves, and this would format-on-save as well. This is the normal format-on-save.

@ryancole
Copy link
Contributor

@ryancole ryancole commented Mar 20, 2018

When using prettier-atom with atom-ide, I also noticed that atom-ide interacts with the diagnostics area of the editor and will complain about linter being installed. You're forced to choose between linter and atom-ide's own package. I'm unsure of whether prettier-atom and atom-ide play super well together, at the moment.

You can ignore prettier-atom's dependency on linter and still get the format on save features, but likely at the cost of the eslint-specific stuff.

@robwise
Copy link
Collaborator

@robwise robwise commented Mar 20, 2018

@ryancole prettier-atom is fully compatible with atom-ide when it comes to diagnostics instead of linter. atom-ide was written so that any package that uses the linter package automatically works with atom-ide instead. If you're using atom-ide, then disable the linter package. You will still get full functionality from prettier-atom as everything we try to send to linter gets automatically picked up by diagnostics instead.

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

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.