dbmrq / vim-bucky

:leaves: Ventilated prose
8 stars 1 forks source link

First impression and handling of comment character #1

Closed kiryph closed 6 years ago

kiryph commented 6 years ago

Thanks for you plugin!

I have tried to use latexindent.pl to format latex text paragraphs. My try can be found here: https://github.com/lervag/vimtex/issues/544#issuecomment-415746300

I share your opinion about the speed of latexindent (written in perl). I am surprised that vimscript can compete.

I did the minimal check whether vim-bucky works for http://dustycloud.org/blog/vcs-friendly-patchable-document-line-wrapping/. Unsurprisingly, it works.

Documentation Maybe, you could mention that by default the textwidth is 78 (hardcoded). But of course this can be changed with the usual vim setting 'textwidth' with its abbreviation 'tw'.

% Character used to split long expression over two lines avoiding additional horizontal space

I have following situation where I have inserted a % to split the long expression xxxxxxxxx} \cite{XxxxxXxXx:xxxx} so that the sentence is a little bit more nicely formatted.

Your plugin, however, treats this as a sentence ending:

Xx xxxxxxxx, xxx xxxxxxxx xxxxxxxxxx, xxxxxxxxxx xxxxxxxxxxx xxxxxxxx xx x
  xxxxxxxx xx xxxx xx xxxxxxx \enquote{xxxxxx xxxx xxxxxxxxx}%
\cite{XxxxxXxXx:xxxx}.
Xxxx x xxxxxxxx xx xxxxxx \emph{xxxxxxx} \cite{XxxxxXxXx:xxxx} xxx xx xxxxxxxx
  xxxxxxxxxxxxx xx x xxxxxxxx \emp{Xxxxxxx'x xxxxx}.

To be fair, latexindent cannot handle this either.

I am not sure if this is impossible or if there are situations which would actually expect that the sentence would end here.

dbmrq commented 6 years ago

Thanks!

Yes, for now there's no documentation at all and no customization options either. I'll start working on that when the main code is more stable, but I'm really busy these next weeks, so it might take a while.

As for the % character, I made it like that intentionally, but that's definitely something that would deserve an option so users can customize that behavior.

I made it like that mostly because of footnotes, so you can do this:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
  eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
  voluptua%
\lorem{Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
  nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed
  diam voluptua.}.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
  amet.

I think it's nice overall to have a way to break sentences manually, there are also a few other odd cases besides the footnote example, and adding a comment seems like a good way to handle that to me. But it's definitely a personal choice, when I start adding customization options I'll add a way to handle this sort of thing.

dbmrq commented 6 years ago

Alright, I just pushed a new commit that should handle this. Now it only treats a comment as sentence ending if it's a single period. That makes it easy to break sentences manually when necessary, but it doesn't mess with the formatting otherwise.

So my example above can now be achieved like this:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
  eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
  voluptua%.
\lorem{Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
  nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed
  diam voluptua.}.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
  amet.

And your example should work properly. :)

kiryph commented 6 years ago

Thanks for the update. I understand your motivation regarding footnotes. I think you solved this elegantly: %. to indicate that this should be considered the end of the sentence by vim-bucky but it is not the actual end.