blob: 45f418e01efe6eff8586b2263f4e4a39f9bf7329 [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
Skyler Grey0c024ef2022-10-31 00:17:14 +00009 if wiki#get_root() != wiki#get_root_global()
10 let g:lastWikiOriginalName = a:name
11 return substitute(g:lastWikiOriginalName, " ", "_", "g")
12 endif
Skyler Greya0ddff72022-09-04 22:07:08 +010013 let l:name = wiki#get_root() . '/' . a:name
Skyler Grey3d1b4502022-10-31 00:11:11 +000014 let g:lastWikiOriginalName = substitute(a:name, "\.private$", "", "")
Skyler Greya0ddff72022-09-04 22:07:08 +010015 " If the file is new, then append the current date
16 return filereadable(l:name)
17 \ ? a:name
Skyler Grey81f4af62022-10-31 00:10:52 +000018 \ : a:name =~ ".*\.private$"
Skyler Grey3d1b4502022-10-31 00:11:11 +000019 \ ? substitute(g:lastWikiOriginalName, " ", "_", "g") . "_" . strftime("%Y%m%d") . ".private"
20 \ : substitute(g:lastWikiOriginalName, " ", "_", "g") . '_' . strftime('%Y%m%d')
Skyler Greya0ddff72022-09-04 22:07:08 +010021endfunction
Skyler Greyaff1ce22022-09-05 03:17:38 +010022
Skyler Grey3d1b4502022-10-31 00:11:11 +000023
24function! TemplateFallback(context)
Skyler Greye9e45852022-10-31 00:16:58 +000025 if exists("g:lastWikiOriginalName")
26 call append(0, ['# ' . g:lastWikiOriginalName, ''])
27 unlet! g:lastWikiOriginalName
28 else
Skyler Grey0c024ef2022-10-31 00:17:14 +000029 call append(0, ['# ' . a:context.name, ''])
Skyler Greye9e45852022-10-31 00:16:58 +000030 endif
Skyler Grey3d1b4502022-10-31 00:11:11 +000031endfunction
32
33let g:wiki_templates = [
34 \ { 'match_func': {x -> v:true},
35 \ 'source_func': function('TemplateFallback')},
36 \]
37
Skyler Greyaff1ce22022-09-05 03:17:38 +010038nnoremap <silent> <Leader>wf :WikiFzfPages<CR>