From e7e2eeba24bcafe3c54befa37b719e38f8182399 Mon Sep 17 00:00:00 2001 From: Lakshay Garg Date: Sun, 14 Apr 2024 08:11:00 -0700 Subject: [PATCH] fix: Improve errorformat for hledger The original errorformat was specified as a multiline format followed by an "ignore non-matching lines format". I encountered some cases where this was problematic: 1. hledger errors have a lot of context spread across multiple lines. Matching everything with 1 multiline format causes vim to move all that information into a single error line which becomes very hard to read. 2. Removing non-matching lines makes it so that if an error is not recognized by efm then it is completely discarded. This can hide errors from the user. For example, in case of an unbalanced transaction hledger prints something like: ``` hledger: Error: :-: | | | | | ... This transaction is unbalanced. The real postings' sum should be 0 but is: Consider adjusting this entry's amounts, or adding missing postings. ``` This error message does not match the old errorformat in the plugin. --- compiler/ledger.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/ledger.vim b/compiler/ledger.vim index e8d8acd..e735d13 100644 --- a/compiler/ledger.vim +++ b/compiler/ledger.vim @@ -33,7 +33,7 @@ if !b:is_hledger exe 'CompilerSet makeprg='.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . substitute(shellescape(expand(g:ledger_main)), ' ', '\\ ', 'g') . '\ '.substitute(g:ledger_extra_options, ' ', '\\ ', 'g').'\ source\ ' . shellescape(expand(g:ledger_main)) else exe 'CompilerSet makeprg='.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . substitute(shellescape(expand(g:ledger_main)), ' ', '\\ ', 'g') . '\ check\ '. substitute(g:ledger_extra_options, ' ', '\\ ', 'g') - CompilerSet errorformat=%Ehledger:\ %trror:\ %f:%l:%c%.%#:,%-C\ \ \|\\s%#,%-C\%l\ \|%.%#,%-C\ \ \|\\s%#,%-C\ \ \|%p^,%+C%m,%-Z\\s%# - " Skip all other lines: - CompilerSet errorformat+=%-G%.%# + CompilerSet errorformat=hledger:\ %trror:\ %f:%l:%c: + CompilerSet errorformat+=hledger:\ %trror:\ %f:%l: + CompilerSet errorformat+=hledger:\ %trror:\ %f:%l-%.%#: endif