Open igbanam opened 2 months ago
That's somewhat surprising! And I've never seen anything like it..
I'm on NeoVIM 0.10 over here, but definitely don't have the same problem:
I'm pretty skeptical that only this plugin alone is causing such a problem, this seems like some weird plugin interaction bug.
Yup! Beats me too. The closest I've come to debugging this is… for some reason, formatoptions=tcqj
is not being respected.
:h fo-table
says this is meant to
t
autowrap text using textwidth
c
autowrap comments using textwidth
q
enable formatting with gq
j
remove the comment character when joining linesDoesn't look like Neovim is autowrapping comments either — peep the …
that indents there
. Looks to me like the line ran out of screen space
My formatoptions
is set to tcqlr12Bj
by default, but I just tried your settings (again my end is NeoVIM) and didn't see a problem.
Are you sure you don't have this issue with other file types?
Holy sheet! I found it 😭😭😭
ledger#align_formatexpr
is effectively ledger#align_commodity
which may not be applicable to comments. Commenting out this line — the one that sets is as formatexpr
— fixes the issue. We don't want to incessantly format while we type. :LedgerAlign
and :LedgerAlignBuffer
can do the job after the typing is done.
On comment lines, it causes the behaviour in the OP. On transaction lines it actually hangs Vim. — I'm curious to see what it does in Neovim.
How to test?
payee
long enough to mark textwidth
textwidth
<C-c>
to unhang itExample
2023-01-01 * lskdjfl skdjf lsdkjflskdjf lskdjf lsdkjf lskdjf lskdjf lksdjf lksdj
Expenses 92837923 USD ; lsdkfsdlfksj-X-kjl
; ^
; |
; here
I just tested this out in Neovim and it doesn't seem to be a problem. The lines don't wrap, but it doesn't hang either
Hold that thought…
In Neovim, g:ledger_max_width=0
(i.e. textwidth=0
) — this may be the reason we don't see the problem in Neovim
NVM it's the same in Vim as well. I don't know why it breaks in Vim and not in Neovim
But commenting out the formatexpr
line works for me
When typing a comment, it wraps to the same line instead of wrapping to a new line.
https://github.com/ledger/vim-ledger/assets/390059/2faa926c-08f2-4b52-bf28-b921d050e600
I haven't done any extra customizations to the plugin. I am on the bleeding edge of Vim 9.