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 |
| 9 | let l:name = wiki#get_root() . '/' . a:name |
Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 10 | let g:lastWikiOriginalName = substitute(a:name, "\.private$", "", "") |
Skyler Grey | a0ddff7 | 2022-09-04 22:07:08 +0100 | [diff] [blame] | 11 | " If the file is new, then append the current date |
| 12 | return filereadable(l:name) |
| 13 | \ ? a:name |
Skyler Grey | 81f4af6 | 2022-10-31 00:10:52 +0000 | [diff] [blame] | 14 | \ : a:name =~ ".*\.private$" |
Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 15 | \ ? substitute(g:lastWikiOriginalName, " ", "_", "g") . "_" . strftime("%Y%m%d") . ".private" |
| 16 | \ : substitute(g:lastWikiOriginalName, " ", "_", "g") . '_' . strftime('%Y%m%d') |
Skyler Grey | a0ddff7 | 2022-09-04 22:07:08 +0100 | [diff] [blame] | 17 | endfunction |
Skyler Grey | aff1ce2 | 2022-09-05 03:17:38 +0100 | [diff] [blame] | 18 | |
Skyler Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 19 | |
| 20 | function! TemplateFallback(context) |
Skyler Grey | e9e4585 | 2022-10-31 00:16:58 +0000 | [diff] [blame^] | 21 | 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 Grey | 3d1b450 | 2022-10-31 00:11:11 +0000 | [diff] [blame] | 29 | endfunction |
| 30 | |
| 31 | let g:wiki_templates = [ |
| 32 | \ { 'match_func': {x -> v:true}, |
| 33 | \ 'source_func': function('TemplateFallback')}, |
| 34 | \] |
| 35 | |
Skyler Grey | aff1ce2 | 2022-09-05 03:17:38 +0100 | [diff] [blame] | 36 | nnoremap <silent> <Leader>wf :WikiFzfPages<CR> |