summary refs log tree commit diff
path: root/.vim/autoload/zettel.vim
blob: 381b8e62f8af430d5fa03a23dcdbfd054aed1f3d (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
" note taking helpers
" to aide in practicing the zettelkasten.de system
"
" ref: https://vimways.org/2019/personal-notetaking-in-vim/

let g:zettel_dir = '~/wiki'
let g:zettel_ext = '.md'

func! zettel#is_zettel(fpath)
    if a:fpath =~ g:zettel_dir . '/.*' . g:zettel_ext . '$' | return 1 | en
    return 0
endfunc

func! zettel#set_filetype()
    silent exec 'setlocal filetype=zettel.' . &filetype
endfunc

func! zettel#edit(...)
    let l:sep = ''
    if len(a:000) > 0
        " argument is a title for the note
        let l:sep = '-'
    endif
    let l:fname = expand(g:zettel_dir) . '/'
        \ . strftime('%Y-%m-%dT%H-%M')
        \ . l:sep . join(a:000, l:sep) . g:zettel_ext

    silent exec 'e ' . l:fname

    " if len(a:000) > 0
    "     silent exec 'normal gg0\<c-r>=strftime("%Y-%m-%d %H:%M")\<cr> '
    "         \ . join(a:000)
    "         \ . '\<cr>\<esc>G'
    " else
    "     silent exec 'normal gg0\<c-r>=strftime("%Y-%m-%d %H:%M")\<cr>\<cr>\<esc>G'
    " endif
endfunc