Open BroodjeKroepoek opened 11 months ago
Hey there :)
We could simply add a newline after each single .
in text mode then
This should be feasible
Thanks for the quick response!
Maybe I'll look into proposing a pull-request myself, if this feature doesn't have that high of a priority. Im not as familiar with the codebase just yet, so i'll have to learn, but im loving using the formatter anyways!
Thanks for your kind words :heart:
I'd ideally like to work on it myself but unfortunately, I'm spending lots of my energy looking for a job right now so PR's are very encouraged ;)
Now that I think about it a bit more...
Maybe if we accept this feature request, it would be not good to also split long sentences by newline in the middle. Since the file you're working in will get very long.
The reason that every sentence on a newline is nice is because you get a certain style guide and certainty. If you are working on a thesis, and you use git to track changes, this will also help with maintainability.
If you still want to have the long sentences being broken up, you can just turn on word wrap (in visual studio code). But I also understand the need to support people that don't use IDE's that have these features.
See image:
But splitting sentences in the middle also makes for a pretty square end result.
I would love to hear, your thoughts on this.
Long in number of lines? I actually think it would be pretty okay to have both (especially since the default line length is quite long and configurable.)
It would be a bit subtle and possibly hacky to have both at once though so I'm not sure If I actually want to support that :thinking:
I was going to request this feature as well. There is some relevant discussion here for vimtex (a comprehensive vim package for LaTeX which includes its own formatexpr
). I agree that mixing one line per sentence with maximum line length could be a bit odd, but I guess I could go either way on that point. One thing to watch out for would be that we wouldn't want to split the line after certain periods in text mode. For example, Mr., Mrs., e.g., c.f., etc., and maybe other commonly used abbreviations.
lot's of abbreviation in fact yes, good remark! Maybe we should only split on .
if there is an uppercase letter after it? that feels a bit silly :thinking:
That's closer, but it still doesn't work for Mr. Hammond is a person.
. It would put a line break after Mr.
since the next letter is uppercase.
Hmm 🤔 anyone has an idea? what is a sentence? 🤣
This project may give some ideas. For a quick solution it may be fine to implement your initial idea with a few manual exceptions (e.g., don't break after Mrs.
, Mr.
, Dr.
, Drs.
).
There's also the possibility/need to let the user add manual exceptions via the config file!
It starts to get complicated if we want to support multiple languages tho :(
(e.g., don't break after
Mrs.
,Mr.
,Dr.
,Drs.
).
You are absolutely correct. A "good enough" solution for me would be a configurable option for typstfmt to just not reflow my paragraphs since I'm already so used to manually writing one-sentence-per-line.
That's actually already the case, you can use word_wrap = false
in config
Maybe I'm missing something in the documentation but where am I supposed to place typstfmt.toml
? (I'm on macos)
Edit: I found it! (via typstfmt --get-global-config-path
)
there's also typstfmt -C
that creates a new local to the project config file! at ./typstfmt.toml
I think!
Currently as of version 0.2.7 (46b4ec34)
Long sentences get split up by adding a newline in the middle. Which is good.
But I would also like to have every sentence on a newline, since this won't impact paragraphs in Typst (same for LaTeX).
Normally I do this manually, I scroll trough the file and put a newline behind every period.
I would be nice if the formatter did this automatically.