blob: b041ec004682b286c6d41451f425834b7e4066d8 (
plain)
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
|
let g:ledger_bin = 'hledger'
let g:ledger_is_hledger = v:true
let g:ledger_align_at = 50
let g:ledger_maxwidth = 80
let g:ledger_commodity_before = 0
let g:ledger_align_commodity = 1
let g:ledger_align_last = v:true
let g:ledger_decimal_sep = '.'
let g:ledger_commodity_sep = ' '
let g:ledger_date_format = '%Y-%m-%d'
let g:ledger_extra_options = ''
let g:ledger_main = expand('$LEDGER_FILE')
function! HLedgerEntry() abort
let l:output = systemlist(join(['hledger', 'print', '--match', getline('.')]))
" Filter out warnings
let l:output = filter(l:output, "v:val !~? '^Warning: '")
" Errors may occur
if v:shell_error
echomsg join(l:output)
return
endif
" Append output so we insert instead of overwrite, then delete line
call append('.', l:output)
normal! "_dd
endfunction
function! s:ledger_keymap() abort
noremap { ?^\d<CR>
noremap } /^\d<CR>
noremap <silent> <buffer> * :call ledger#transaction_state_toggle(line('.'), ' *!')<CR>
nnoremap <silent> <buffer> <Tab> vip!hledger -f- print<CR>
inoremap <silent> <buffer> <c-x><c-x> <c-o>:call HLedgerEntry()<CR>
endfunction
au FileType ledger call s:ledger_keymap()
|