From 9f853addd1fdb44966eaaf904114542061a38c5b Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Tue, 10 Mar 2020 17:37:03 +0100 Subject: Replace AlignCommodity with bean-format AlignCommodity replicates the functionality of the bean-format command that is shipped with beancount itself. Therefore, we can fully replace it by having vim invoke bean-format through formatprg. Even though bean-format's output might differ from AlignCommodity in significant ways, we feel that using one unified tool is superior to having several (possibly incompatible) custom implementations. That way, if bean-format is improved upon in the future, all downstream consumers profit. For regular usage, however, this change should be transparent. Note that while bean-format supports a few different ways of formatting the ledger, we have opted to hard-code one specific setting. This will match the default behaviour of fava, aligning currencies in column 61. Managing the arguments passed to bean-format dynamically is considered out of scope, especially given the fact that the user need only override formatprg to get a custom setting. This commit will also drop the g:beancount_separator_col variable and the tests for AlignCommodity. Ideally, testing will now done upstream for bean-format itself. --- ftplugin/beancount.vim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'ftplugin/beancount.vim') diff --git a/ftplugin/beancount.vim b/ftplugin/beancount.vim index b6e3540..ab54905 100644 --- a/ftplugin/beancount.vim +++ b/ftplugin/beancount.vim @@ -3,17 +3,14 @@ if exists('b:did_ftplugin') endif let b:did_ftplugin = 1 -let b:undo_ftplugin = 'setlocal foldmethod< comments< commentstring<' +let b:undo_ftplugin = 'setlocal foldmethod< formatprg< comments< commentstring<' setl foldmethod=syntax +setl formatprg=bean-format\ -c61 setl comments=b:; setl commentstring=;%s compiler beancount -" This variable customizes the behavior of the AlignCommodity command. -if !exists('g:beancount_separator_col') - let g:beancount_separator_col = 50 -endif if !exists('g:beancount_account_completion') let g:beancount_account_completion = 'default' endif @@ -21,9 +18,6 @@ if !exists('g:beancount_detailed_first') let g:beancount_detailed_first = 0 endif -command! -buffer -range AlignCommodity - \ :call beancount#align_commodity(, ) - command! -buffer -range GetContext \ :call beancount#get_context() -- cgit v1.2.3-2-gb3c3