Skyler Grey | e75e926 | 2022-09-04 22:02:09 +0100 | [diff] [blame] | 1 | let g:wiki_root = '~/Documents/wiki' |
Skyler Grey | a0ddff7 | 2022-09-04 22:07:08 +0100 | [diff] [blame] | 2 | let g:wiki_filetypes = ['md'] |
| 3 | let g:wiki_link_extension = '.md' |
Skyler Grey | 81f4af6 | 2022-10-31 00:10:52 +0000 | [diff] [blame] | 4 | let g:wiki_index_name = 'README' |
Skyler Grey | a0ddff7 | 2022-09-04 22:07:08 +0100 | [diff] [blame] | 5 | |
| 6 | |
| 7 | let g:wiki_map_create_page = 'WikiCreateTransform' |
| 8 | function WikiCreateTransform(name) abort |
Skyler Grey | 0c024ef | 2022-10-31 00:17:14 +0000 | [diff] [blame] | 9 | if wiki#get_root() != wiki#get_root_global() |
| 10 | let g:lastWikiOriginalName = a:name |
| 11 | return substitute(g:lastWikiOriginalName, " ", "_", "g") |
| 12 | endif |
Skyler Grey | a0ddff7 | 2022-09-04 22:07:08 +0100 | [diff] [blame] | 13 | let l:name = wiki#get_root() . '/' . a:name |
Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 14 | let g:lastWikiOriginalName = substitute(a:name, "\.private$", "", "") |
Skyler Grey | a0ddff7 | 2022-09-04 22:07:08 +0100 | [diff] [blame] | 15 | " If the file is new, then append the current date |
| 16 | return filereadable(l:name) |
| 17 | \ ? a:name |
Skyler Grey | 81f4af6 | 2022-10-31 00:10:52 +0000 | [diff] [blame] | 18 | \ : a:name =~ ".*\.private$" |
Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 19 | \ ? substitute(g:lastWikiOriginalName, " ", "_", "g") . "_" . strftime("%Y%m%d") . ".private" |
| 20 | \ : substitute(g:lastWikiOriginalName, " ", "_", "g") . '_' . strftime('%Y%m%d') |
Skyler Grey | a0ddff7 | 2022-09-04 22:07:08 +0100 | [diff] [blame] | 21 | endfunction |
Skyler Grey | aff1ce2 | 2022-09-05 03:17:38 +0100 | [diff] [blame] | 22 | |
Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 23 | |
| 24 | function! TemplateFallback(context) |
Skyler Grey | e9e4585 | 2022-10-31 00:16:58 +0000 | [diff] [blame] | 25 | if exists("g:lastWikiOriginalName") |
| 26 | call append(0, ['# ' . g:lastWikiOriginalName, '']) |
| 27 | unlet! g:lastWikiOriginalName |
| 28 | else |
Skyler Grey | 0c024ef | 2022-10-31 00:17:14 +0000 | [diff] [blame] | 29 | call append(0, ['# ' . a:context.name, '']) |
Skyler Grey | e9e4585 | 2022-10-31 00:16:58 +0000 | [diff] [blame] | 30 | endif |
Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 31 | endfunction |
| 32 | |
| 33 | let g:wiki_templates = [ |
| 34 | \ { 'match_func': {x -> v:true}, |
| 35 | \ 'source_func': function('TemplateFallback')}, |
| 36 | \] |
| 37 | |
Skyler Grey | aff1ce2 | 2022-09-05 03:17:38 +0100 | [diff] [blame] | 38 | nnoremap <silent> <Leader>wf :WikiFzfPages<CR> |