Closed greg-minshall closed 2 years ago
Pervasive automatic code formatting has been one of the greatest quality of life improvements for me as a software developer. Now that I'm used to it I sorely miss it when I can't use it, such as when writing SQL.
It's liberating not having to spend a moment's thought on the boring minutiae of syntax. Sure, your code changing shape on save takes some getting used to, but it's a minuscule price to pay compared to the benefits. I urge you to give it a try again.
At any rate, your example code doesn't seem to depend on this package (it's invoking Prettier proper as an external one-off process) so I don't see a reason for it to be added here anyway. Good luck!
hi, Julian, thanks for the reply. yes, probably if i would get used to the shape-shifting. that may happen. the rough code i showed above is "lazy" and uses whatever prettier is around. were you to integrate it into prettier.el, then i assumed you'd make use of your own internal prettier.
anyway, maybe this is my "chance" to write/publish my own micro-package. (but, is it an 'lpu'? :)
cheers.
Have you tried binding prettier-prettify to a key and using that to reformat on demand?
no, i haven't. maybe it's stone-age-related short term memory problems -- but, i want to see the diff bewteen what i typed and what prettier wants, on a case-by-case basis. vdiff gives me the comparision (and that's a lot better for me than waving the magic wand), but i'd rather have something like diff mode (which i couldn't figure out how to get to work with Org src edit buffers; it seems to really want to have a backing file).
Julian, for your Entertainment, Experimentation, if you have a chance:
and, for my Edification, if you have any comments, critiques about the code, packaging, documentation -- i'm all ears! cheers.
Is your feature request related to a problem? Please describe.
i would like to train my brain/fingers to type "prettier-conformant" code. (one of the reasons for my #98.)
Describe the solution you'd like
my suggestion is a way to bring up a diff-style pair of buffers, where one is my un-conformant code, and the other, a diff listing (
-c
or-u
, if possible --magit
is great for this). then, allow the user ton
/p
their way through the code/diffs, andr
, or something, to pull in the new formatting.Describe alternatives you've considered
i have some shell code that does the diff part in the shell. it's useful, but not as convenient as one might like.
i also have some elisp code that uses
vdiff
, and assumes a locally installedprettier
executable. it works nicely, is a hack, and doesn't seem to allow what i thinkmagit
allows: highlighting the individual characters within a hunk that have changed. since it's long, i'll put it below.Additional context here is my hacky elisp code. as the comments indicate, part of the complexity is dealing with
Org Src
edit (or, presumably, other non-file-specific) buffers.