summaryrefslogtreecommitdiffstats
path: root/compiler/ledger.vim
blob: f74a27a20cd4f19953a7facb9e4d592b8eeced4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
let files = filter(globpath(&rtp, 'compiler/ledger.vim', 1, 1), { _, v -> v !~ "vim-polyglot" && v !~ $VIMRUNTIME && v !~ "after" })
if len(files) > 0
  exec 'source ' . files[0]
  finish
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ledger') == -1

" Vim Compiler File
" Compiler:	ledger
" by Johann Klähn; Use according to the terms of the GPL>=2.
" vim:ts=2:sw=2:sts=2:foldmethod=marker

scriptencoding utf-8

if exists('current_compiler') || !exists('g:ledger_bin')
  finish
endif

let current_compiler = g:ledger_bin

if exists(':CompilerSet') != 2
  command -nargs=* CompilerSet setlocal <args>
endif

if !exists('g:ledger_main')
  let g:ledger_main = '%'
endif

if !g:ledger_is_hledger
	" Capture Ledger errors (%-C ignores all lines between "While parsing..." and "Error:..."):
	CompilerSet errorformat=%EWhile\ parsing\ file\ \"%f\"\\,\ line\ %l:,%ZError:\ %m,%-C%.%#
	" Capture Ledger warnings:
	CompilerSet errorformat+=%tarning:\ \"%f\"\\,\ line\ %l:\ %m
	" Skip all other lines:
	CompilerSet errorformat+=%-G%.%#
	exe 'CompilerSet makeprg='.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . shellescape(expand(g:ledger_main)) . '\ '.substitute(g:ledger_extra_options, ' ', '\\ ', 'g').'\ source\ ' . shellescape(expand(g:ledger_main))
else
	exe 'CompilerSet makeprg=('.substitute(g:ledger_bin, ' ', '\\ ', 'g').'\ -f\ ' . shellescape(expand(g:ledger_main)) . '\ print\ '.substitute(g:ledger_extra_options, ' ', '\\ ', 'g').'\ >\ /dev/null)'
endif

endif