From 0570c9c416a3cdad9c312a392300413d979696ac Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Sat, 14 Aug 2010 12:24:46 +0200 Subject: vim. display warning messages in quickfix window To use this option you must set g:ledger_bin = "ledger --strict" before the compiler plugin is loaded (your .vimrc for example). --- contrib/vim/compiler/ledger.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'contrib/vim/compiler') diff --git a/contrib/vim/compiler/ledger.vim b/contrib/vim/compiler/ledger.vim index 33b019cb..b6bb7fb4 100644 --- a/contrib/vim/compiler/ledger.vim +++ b/contrib/vim/compiler/ledger.vim @@ -12,7 +12,7 @@ if exists(":CompilerSet") != 2 command -nargs=* CompilerSet setlocal endif -if ! exists("g:ledger_bin") || ! executable(g:ledger_bin) +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 @@ -24,8 +24,9 @@ endif " %-G throws away blank lines, everything else is assumed to be part of a " multi-line error message. CompilerSet errorformat=%-G,%EWhile\ parsing\ file\ \"%f\"\\,\ line\ %l:%.%#,%ZError:\ %m,%C%.%# +CompilerSet errorformat+=%tarning:\ \"%f\"\\,\ line\ %l:\ %m " unfortunately there is no 'check file' command, " so we will just use a query that returns no results. ever. -exe 'CompilerSet makeprg='.g:ledger_bin.'\ -f\ %\ reg\ not\ ''.*''\ \>\ /dev/null' +exe 'CompilerSet makeprg='.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ %\ reg\ not\ ''.*''\ \>\ /dev/null' -- cgit v1.2.3 From 04f564f01c9395188c1bc0d890745ad15eb3fc2f Mon Sep 17 00:00:00 2001 From: Johann Klähn Date: Tue, 7 Sep 2010 17:59:26 +0200 Subject: 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 --- contrib/vim/compiler/ledger.vim | 8 ++------ contrib/vim/ftplugin/ledger.vim | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'contrib/vim/compiler') 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 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 -- cgit v1.2.3