ledger / vim-ledger

Vim plugin for Ledger
GNU General Public License v2.0
372 stars 55 forks source link

omni completion gives opaque error "Pattern not found" when ledger contains an unbalanced transaction #146

Closed atsaloli closed 5 months ago

atsaloli commented 1 year ago

I accidentally introduced an unbalanced transaction in my ledger and when I tried to use omni completion the next time after I saved the file, I got an error "Pattern not found".

It would have been a lot easier to debug this if I saw a ledger error instead telling me it's an unbalanced transaction.

Is there any way for omni complete to pass the ledger error through, please?

alerque commented 5 months ago

I don't think this is feasible, the omnicompletion mechanism is not designed to also do linting on the file and validate that it is parsing properly.

You can however do this at save time with a hook that uses the compiler tooling to make sure the file can be parsed properly. That tooling in VIM is already setup to expose errors in the file. Note this plugin already has compiler tooling to setup makeprg for your ledger tool. You might need to fiddle with the extra options to run something appropriate for your data files that validates that they parse correctly.