blob: 77d9100b2c8234b3c8d4b7de98936fa735424a1f [file] [log] [blame]
Skyler Greye75e9262022-09-04 22:02:09 +01001let g:wiki_root = '~/Documents/wiki'
Skyler Greya0ddff72022-09-04 22:07:08 +01002let g:wiki_filetypes = ['md']
3let g:wiki_link_extension = '.md'
Skyler Grey81f4af62022-10-31 00:10:52 +00004let g:wiki_index_name = 'README'
Skyler Greya0ddff72022-09-04 22:07:08 +01005
6
7let g:wiki_map_create_page = 'WikiCreateTransform'
8function WikiCreateTransform(name) abort
9 let l:name = wiki#get_root() . '/' . a:name
Skyler Grey3d1b4502022-10-31 00:11:11 +000010 let g:lastWikiOriginalName = substitute(a:name, "\.private$", "", "")
Skyler Greya0ddff72022-09-04 22:07:08 +010011 " If the file is new, then append the current date
12 return filereadable(l:name)
13 \ ? a:name
Skyler Grey81f4af62022-10-31 00:10:52 +000014 \ : a:name =~ ".*\.private$"
Skyler Grey3d1b4502022-10-31 00:11:11 +000015 \ ? substitute(g:lastWikiOriginalName, " ", "_", "g") . "_" . strftime("%Y%m%d") . ".private"
16 \ : substitute(g:lastWikiOriginalName, " ", "_", "g") . '_' . strftime('%Y%m%d')
Skyler Greya0ddff72022-09-04 22:07:08 +010017endfunction
Skyler Greyaff1ce22022-09-05 03:17:38 +010018
Skyler Grey3d1b4502022-10-31 00:11:11 +000019
20function! TemplateFallback(context)
Skyler Greye9e45852022-10-31 00:16:58 +000021 echom "Creating new wiki page"
22 echom exists("g:lastWikiOriginalName")
23 if exists("g:lastWikiOriginalName")
24 call append(0, ['# ' . g:lastWikiOriginalName, ''])
25 unlet! g:lastWikiOriginalName
26 else
27 call append(0, ['# ' . context.name, ''])
28 endif
Skyler Grey3d1b4502022-10-31 00:11:11 +000029endfunction
30
31let g:wiki_templates = [
32 \ { 'match_func': {x -> v:true},
33 \ 'source_func': function('TemplateFallback')},
34 \]
35
Skyler Greyaff1ce22022-09-05 03:17:38 +010036nnoremap <silent> <Leader>wf :WikiFzfPages<CR>