diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2022-10-14 17:40:10 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2022-10-14 17:40:10 +0200 |
commit | bc8a81d3592dab86334f27d1d43c080ebf680d42 (patch) | |
tree | f367857d8c196d36f2d6dec3c2f6c9d703b06b7c /autoload/ledger.vim | |
parent | 38282d58387cff48ac203f6912c05e4c8686141b (diff) | |
download | vim-polyglot-bc8a81d3592dab86334f27d1d43c080ebf680d42.tar.gz vim-polyglot-bc8a81d3592dab86334f27d1d43c080ebf680d42.zip |
Update
Diffstat (limited to 'autoload/ledger.vim')
-rw-r--r-- | autoload/ledger.vim | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/autoload/ledger.vim b/autoload/ledger.vim index 90c88802..984070c0 100644 --- a/autoload/ledger.vim +++ b/autoload/ledger.vim @@ -25,7 +25,7 @@ function! ledger#transaction_state_toggle(lnum, ...) abort endf function! ledger#transaction_state_set(lnum, char) abort - " modifies or sets the state of the transaction at the cursor, + " modifies or sets the state of the transaction at the given line no., " removing the state altogether if a:char is empty let trans = s:transaction.from_lnum(a:lnum) if empty(trans) || has_key(trans, 'expr') @@ -130,7 +130,7 @@ function! ledger#transaction_post_state_set(lnum, char) abort return endif - let line = getline('.') + let line = getline(a:lnum) if a:char =~# '^\s*$' let newline = substitute(line, '\V' . state . '\m[ \t]', '', '') elseif state ==# ' ' @@ -457,10 +457,20 @@ endf " Return character position of decimal separator (multibyte safe) function! s:decimalpos(expr) abort - let pos = match(a:expr, '\V' . g:ledger_decimal_sep) - if pos > 0 - let pos = strchars(a:expr[:pos]) - 1 - endif + " Remove trailing comments + let l:expr = substitute(a:expr, '\v +;.*$', '', '') + " Find first or last possible decimal separator candidate + if g:ledger_align_last + let pos = matchend(l:expr, '\v.*[' . g:ledger_decimal_sep . ']') + if pos > 0 + let pos = strchars(a:expr[:pos]) + 1 + endif + else + let pos = match(l:expr, '\v[' . g:ledger_decimal_sep . ']') + if pos > 0 + let pos = strchars(a:expr[:pos]) - 1 + endif + end return pos endf @@ -544,6 +554,10 @@ function! ledger#align_amount_at_cursor() abort endif endf +function! ledger#align_formatexpr(lnum, count) abort + execute a:lnum . ',' . (a:lnum + a:count - 1) . 'call ledger#align_commodity()' +endfunction + " Report generation {{{1 " Helper functions and variables {{{2 @@ -732,8 +746,6 @@ function! ledger#register(file, args) abort endf " Reconcile the given account. -" This function accepts a file path as a third optional argument. -" The default is to use the value of g:ledger_main. " " Parameters: " file The file to be processed |