diff --git a/nvim/.config/nvim/plugin/wiki.vim b/nvim/.config/nvim/plugin/wiki.vim index bdbcbc4..25854cf 100644 --- a/nvim/.config/nvim/plugin/wiki.vim +++ b/nvim/.config/nvim/plugin/wiki.vim @@ -7,6 +7,35 @@ 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_link_extension = '.md' -let g:wiki_link_target_type = 'md' 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]']