summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/vim/compiler/ledger.vim8
-rw-r--r--contrib/vim/ftplugin/ledger.vim17
2 files changed, 18 insertions, 7 deletions
diff --git a/contrib/vim/compiler/ledger.vim b/contrib/vim/compiler/ledger.vim
index b6bb7fb4..e9e98a8e 100644
--- a/contrib/vim/compiler/ledger.vim
+++ b/contrib/vim/compiler/ledger.vim
@@ -12,13 +12,9 @@ if exists(":CompilerSet") != 2
command -nargs=* CompilerSet setlocal <args>
endif
+" default value will be set in ftplugin
if ! exists("g:ledger_bin") || empty(g:ledger_bin) || ! executable(split(g:ledger_bin, '\s')[0])
- if executable('ledger')
- let g:ledger_bin = 'ledger'
- else
- echoerr "ledger command not found. Set g:ledger_bin or extend $PATH."
- finish
- endif
+ finish
endif
" %-G throws away blank lines, everything else is assumed to be part of a
diff --git a/contrib/vim/ftplugin/ledger.vim b/contrib/vim/ftplugin/ledger.vim
index d75a6869..c5354508 100644
--- a/contrib/vim/ftplugin/ledger.vim
+++ b/contrib/vim/ftplugin/ledger.vim
@@ -12,7 +12,7 @@ let b:did_ftplugin = 1
let b:undo_ftplugin = "setlocal ".
\ "foldmethod< foldtext< ".
- \ "include< comments< omnifunc< "
+ \ "include< comments< omnifunc< formatprg<"
" don't fill fold lines --> cleaner look
setl fillchars="fold: "
@@ -22,6 +22,21 @@ setl include=^!include
setl comments=b:;
setl omnifunc=LedgerComplete
+" set location of ledger binary for checking and auto-formatting
+if ! exists("g:ledger_bin") || empty(g:ledger_bin) || ! executable(split(g:ledger_bin, '\s')[0])
+ if executable('ledger')
+ let g:ledger_bin = 'ledger'
+ else
+ unlet g:ledger_bin
+ echoerr "ledger command not found. Set g:ledger_bin or extend $PATH ".
+ \ "to enable error checking and auto-formatting."
+ endif
+endif
+
+if exists("g:ledger_bin")
+ exe 'setl formatprg='.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ -\ print'
+endif
+
" You can set a maximal number of columns the fold text (excluding amount)
" will use by overriding g:ledger_maxwidth in your .vimrc.
" When maxwidth is zero, the amount will be displayed at the far right side