When creating a new link within notes, using the wiki.vim openlink shortcut (return by default), it will prepend a Zettelkasten-like unique id based on current time in front of the link. It will also lowercase it and substitute spaces for dashes.
41 lines
1.3 KiB
VimL
41 lines
1.3 KiB
VimL
" PLUGIN: wiki.vim
|
|
if $WIKIROOT ==? ""
|
|
let g:wiki_root = expand('~/documents/notes')
|
|
else
|
|
let g:wiki_root = $WIKIROOT
|
|
endif
|
|
" filetypes to automatically enable the plugin for, seems to take file endings
|
|
" rather than vim ft
|
|
let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki']
|
|
let g:wiki_mappings_use_defaults = 1
|
|
|
|
" wiki automatic link creation
|
|
" add .md to the end of links by default
|
|
let g:wiki_link_extension = '.md'
|
|
" add a link in the format [descr](target) by default
|
|
" not in wiki format [[link|descr]]
|
|
let g:wiki_link_target_type = 'md'
|
|
|
|
" Creates a Zettelkasten compatible unique datestamp
|
|
function s:Getdatestamp()
|
|
if !exists("*strftime")
|
|
:echoerr "Date Stamp creation needs strftime available on system!"
|
|
endif
|
|
return strftime("%y%m%d%H%M")
|
|
endfunction
|
|
|
|
command! Datestamp :echom s:Getdatestamp()
|
|
|
|
" Appends Zettelkasten timestamp to beginning of links
|
|
function! PrependDatestamp(text) abort
|
|
" lowercase and replace spaces with dashes (-) to make links uniform
|
|
let l:text=substitute(tolower(a:text), '\s\+', '-', 'g')
|
|
" prepend datestamp
|
|
let l:text=substitute(l:text, '^', s:Getdatestamp() . ' '. '\0', 'g')
|
|
return l:text
|
|
endfunction
|
|
|
|
" sets wiki.vim to automatically apply datestamp function to links
|
|
let g:wiki_link_target_map = "PrependDatestamp"
|
|
|
|
let g:wiki_list_todos = ['[ ]', '[x]']
|