This commit is contained in:
gbaconni
2021-10-29 06:02:17 +00:00
parent ba5cb17459
commit 483d1c500b
3 changed files with 12 additions and 215 deletions

View File

@@ -33,7 +33,7 @@ let s:types = {
\['!', '!', '/']
\}
function! s:filetype()
function s:filetype()
let l:f = s:filename()
let s:start = '#'
@@ -50,17 +50,17 @@ function! s:filetype()
endfunction
function! s:ascii(n)
function s:ascii(n)
return s:asciiart[a:n - 3]
endfunction
function! s:textline(left, right)
function s:textline(left, right)
let l:left = strpart(a:left, 0, s:length - s:margin * 3 - strlen(a:right) + 1)
return s:start . repeat(' ', s:margin - strlen(s:start)) . l:left . repeat(' ', s:length - s:margin * 2 - strlen(l:left) - strlen(a:right)) . a:right . repeat(' ', s:margin - strlen(s:end)) . s:end
endfunction
function! s:line(n)
function s:line(n)
if a:n == 1 || a:n == 11 " top and bottom line
return s:start . ' ' . repeat(s:fill, s:length - strlen(s:start) - strlen(s:end) - 2) . ' ' . s:end
elseif a:n == 2 || a:n == 10 " blank line
@@ -78,7 +78,7 @@ function! s:line(n)
endif
endfunction
function! s:user()
function s:user()
let l:user = $USER
if strlen(l:user) == 0
let l:user = "marvin"
@@ -86,7 +86,7 @@ function! s:user()
return l:user
endfunction
function! s:mail()
function s:mail()
let l:mail = $MAIL
if strlen(l:mail) == 0
let l:mail = "marvin@42.fr"
@@ -94,7 +94,7 @@ function! s:mail()
return l:mail
endfunction
function! s:filename()
function s:filename()
let l:filename = expand("%:t")
if strlen(l:filename) == 0
let l:filename = "< new >"
@@ -102,11 +102,11 @@ function! s:filename()
return l:filename
endfunction
function! s:date()
function s:date()
return strftime("%Y/%m/%d %H:%M:%S")
endfunction
function! s:insert()
function s:insert()
let l:line = 11
" empty line after header
@@ -119,7 +119,7 @@ function! s:insert()
endwhile
endfunction
function! s:update()
function s:update()
call s:filetype()
if getline(9) =~ s:start . repeat(' ', s:margin - strlen(s:start)) . "Updated: "
if &mod
@@ -131,13 +131,13 @@ function! s:update()
return 1
endfunction
function! s:stdheader()
function s:stdheader()
if s:update()
call s:insert()
endif
endfunction
" Bind command and shortcut
command! Stdheader call s:stdheader ()
command Stdheader call s:stdheader ()
map <F1> :Stdheader<CR>
autocmd BufWritePre * call s:update ()