aboutsummaryrefslogtreecommitdiffstats
path: root/ftplugin/beancount.vim
blob: 277285eec45a8420632d17e769120e25e7b5800b (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
42
" These two variables customize the behavior of the AlignCommodity command.

if exists("b:did_ftplugin")
  finish
endif

let b:did_ftplugin = 1
let b:undo_ftplugin = "setlocal foldmethod< comments< commentstring<"

setl foldmethod=marker
setl comments=b:;
setl commentstring=;%s

if !exists("g:beancount_separator_col")
    let g:beancount_separator_col = 50
endif
if !exists("g:beancount_decimal_separator")
    let g:beancount_decimal_separator = "."
endif

command! -range AlignCommodity :call beancount#align_commodity(<line1>, <line2>)

" Align commodity to proper column
inoremap <buffer> . .<C-O>:AlignCommodity<CR>
nnoremap <buffer> <leader>= :AlignCommodity<CR>
vnoremap <buffer> <leader>= :AlignCommodity<CR>

" Insert incoming transactions at the bottom
function! s:InsertIncoming()
    let incoming = expand('%:h') . '/incoming.bean'
    try
        execute '$read' incoming
        call system('mv ' . incoming . ' ' . incoming . '~')
    catch /:E484/
        echom "Not found: incoming.bean"
    endtry
endfunction

command! -buffer Incoming call <SID>InsertIncoming()


setl omnifunc=beancount#complete_account