vim. use ledger print as 'formatprg'

You can now try to select some lines using V (visual mode)
and have them automatically formatted using gq
This commit is contained in:
Johann Klähn 2010-09-07 17:59:26 +02:00
parent 0570c9c416
commit 04f564f01c
2 changed files with 18 additions and 7 deletions

View file

@ -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

View file

@ -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