Update 2026-01-25 09:38 OpenBSD/amd64-t14
This commit is contained in:
@@ -1,17 +1,23 @@
|
||||
" Vim filetype indent file
|
||||
" filetype: ledger
|
||||
" by Johann Klähn; Use according to the terms of the GPL>=2.
|
||||
" vim:ts=2:sw=2:sts=2:foldmethod=marker
|
||||
" SPDX-FileCopyrightText: © 2019 Caleb Maclennan <caleb@alerque.com>
|
||||
" SPDX-FileCopyrightText: © 2009 Johann Klähn <kljohann@gmail.com>
|
||||
" SPDX-FileCopyrightText: © 2009 Stefan Karrmann
|
||||
" SPDX-FileCopyrightText: © 2005 Wolfgang Oertl
|
||||
" SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
if exists("b:did_indent")
|
||||
scriptencoding utf-8
|
||||
|
||||
call ledger#init()
|
||||
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
setl autoindent
|
||||
setl indentexpr=GetLedgerIndent()
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetLedgerIndent()
|
||||
|
||||
if exists("*GetLedgerIndent")
|
||||
if exists('*GetLedgerIndent')
|
||||
finish
|
||||
endif
|
||||
|
||||
@@ -23,18 +29,18 @@ function GetLedgerIndent(...)
|
||||
let line = getline(lnum)
|
||||
let prev = getline(lnum - 1)
|
||||
|
||||
if line =~ '^\s\+\S'
|
||||
if line =~# '^\s\+\S'
|
||||
" Lines that already are indented (→postings, sub-directives) keep their indentation.
|
||||
return &sw
|
||||
elseif line =~ '^\s*$'
|
||||
return shiftwidth()
|
||||
elseif line =~# '^\s*$'
|
||||
" Current line is empty, try to guess its type based on the previous line.
|
||||
if prev =~ '^\([[:digit:]~=]\|\s\+\S\)'
|
||||
if prev =~# '^\([[:digit:]~=]\|\s\+\S\)'
|
||||
" This is very likely a posting or a sub-directive.
|
||||
" While lines following the start of a transaction are automatically
|
||||
" indented you will have to indent the first line following a
|
||||
" pre-declaration manually. This makes it easier to type long lists of
|
||||
" 'account' pre-declarations without sub-directives, for example.
|
||||
return &sw
|
||||
return shiftwidth()
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
@@ -43,4 +49,4 @@ function GetLedgerIndent(...)
|
||||
" start of transactions, pre-declarations, apply/end-lines
|
||||
return 0
|
||||
endif
|
||||
endf
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user