-
Notifications
You must be signed in to change notification settings - Fork 148
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
feature request : format block of text #65
Comments
I think there are two parts to this: one is being able to send elm-format input on stdin instead of in a file, and the other is to be able to parse and format inputs that are not complete files. (In your example, you have a definition selected.) What editor is your plugin for? |
True ! Light Table: https://github.com/rundis/elm-light cheers |
How can we break this down to implement incrementally? Would being able to format declarations be enough to start with? What other smaller pieces would you expect to want to format? (expressions, types, patterns, ...?) |
Anything beyond that goes into the nice-to-have category |
Great news ! I should build from source to test this or have the distributions been updated ? @avh4 Nah formatting and executing doesn't/shouldn't depend on each other. I wasn't planning on limiting this to just the repl btw.. But to any elm buffer/file in Light Table. Let me outline a few scenarios:
|
Thanks for the extra comments @rundis . For the latter two cases, the hope is that For the repl case, do we know exactly what types of things the repl accepts? It must accept both top-level definitions, and expressions. Would you know in advance which it is? I'm guessing you'd probably want |
My biggest fear is that there will be too strict requirements on always having your entire working file in a completely valid state for partial changes to be workable/usable. I might be uncessarily worried but I remember that was one of the reasons I switched from Eclipse to Intellij back in the day. Eclipse depended on everything compiling nicely for things too work, a few errors and it was totally thrown off. With regards to the repl, it accepts a lot of things I'm afraid. I mean you can write |
Chiming in as a Vim user — elm-format is quite fast enough to format the entire file, but sometimes I feel like "attaching" comments to blocks of code by having a comment on e.g. an immediately preceding line. Formatting the entire file breaks this, of course, but Vim has However, since elm-format inserts a module definition if it finds none, this causes spurious |
Fair enough :) I didn't know about –Ilkka
|
Glad to find this discussion! I began to work on a new feature in Because
What would be ideal in my scenario is if |
I started a PR in Who could have a look at solving this issue please? |
#369 is a feature on the 0.7.1 backlog that will pave the way for this to happen. We also need to finalize a design on how this should work: what should the command line argument(s) be, and can it be possible to detect this mode automatically based on the input? |
Meanwhile, I managed to solve an issue with formatting code fragments in markdown by implementing Elm plugin for Prettier. It calls |
This is sort of implemented internally now for when elm-format formats pieces of code in doc comments. The logic is here: elm-format/src/ElmFormat/Render/Box.hs Lines 671 to 678 in 0fae81f
I guess the question now is how should this be exposed to external tools? |
@avh4 something like |
One way could be to add a flag, but another one with a simpler design would be to stop adding the Is this feature useful to some? I fail to see much use cases for it but it may be only because I'm not used to it. Maybe uses cases have been listed somewhere or a poll could be done on slack or something to evaluate the usefulness of this feature? |
I'm excited about this project ! I was wondering if it would be possible to also support formatting of a block of text. Why would you need that you might ask ? Well I've created a editor plugin for elm and one of the features is a repl integration. When working in a repl context in the editor, there is no file backing the editor however it would be really nice to be able to format expressions when you are repl'ing away so to speak.
Let me illustrate:
The text was updated successfully, but these errors were encountered: