parent
23ee20887a
commit
6221861957
@ -335,7 +335,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{
|
||||
|
||||
let link_infos.filename =
|
||||
\ VimwikiGet('path', link_infos.index) .
|
||||
\ VimwikiGet('diary_rel_path', link_infos.index) .
|
||||
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
|
||||
\ link_text .
|
||||
\ VimwikiGet('ext', link_infos.index)
|
||||
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local')
|
||||
@ -520,7 +520,7 @@ function! vimwiki#base#find_files(wiki_nr, directories_only)
|
||||
if wiki_nr >= 0
|
||||
let root_directory = VimwikiGet('path', wiki_nr)
|
||||
else
|
||||
let root_directory = VimwikiGet('path').VimwikiGet('diary_rel_path')
|
||||
let root_directory = VimwikiGet('path').vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
let wiki_nr = g:vimwiki_current_idx
|
||||
endif
|
||||
if a:directories_only
|
||||
@ -548,7 +548,7 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
|
||||
if a:wiki_nr == g:vimwiki_current_idx
|
||||
let cwd = vimwiki#path#wikify_path(expand('%:p:h'))
|
||||
elseif a:wiki_nr < 0
|
||||
let cwd = VimwikiGet('path').VimwikiGet('diary_rel_path')
|
||||
let cwd = VimwikiGet('path').vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
else
|
||||
let cwd = VimwikiGet('path', a:wiki_nr)
|
||||
endif
|
||||
@ -563,7 +563,7 @@ function! vimwiki#base#get_wikilinks(wiki_nr, also_absolute_links)
|
||||
if a:wiki_nr == g:vimwiki_current_idx
|
||||
let cwd = VimwikiGet('path')
|
||||
elseif a:wiki_nr < 0
|
||||
let cwd = VimwikiGet('path').VimwikiGet('diary_rel_path')
|
||||
let cwd = VimwikiGet('path').vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
endif
|
||||
let wikifile = fnamemodify(wikifile, ':r') " strip extension
|
||||
let wikifile = '/'.vimwiki#path#relpath(cwd, wikifile)
|
||||
@ -1856,7 +1856,7 @@ endfunction " }}}
|
||||
" s:is_diary_file
|
||||
function! s:is_diary_file(filename) " {{{
|
||||
let file_path = vimwiki#path#path_norm(a:filename)
|
||||
let rel_path = VimwikiGet('diary_rel_path')
|
||||
let rel_path = vimwiki#vars#get_wikilocal('diary_rel_path')
|
||||
let diary_path = vimwiki#path#path_norm(VimwikiGet('path') . rel_path)
|
||||
return rel_path != ''
|
||||
\ && file_path =~# '^'.vimwiki#u#escape(diary_path)
|
||||
@ -1889,7 +1889,7 @@ function! s:normalize_link_in_diary(lnk) " {{{
|
||||
let link = a:lnk . VimwikiGet('ext')
|
||||
let link_wiki = VimwikiGet('path') . '/' . link
|
||||
let link_diary = VimwikiGet('path') . '/'
|
||||
\ . VimwikiGet('diary_rel_path') . '/' . link
|
||||
\ . vimwiki#vars#get_wikilocal('diary_rel_path') . '/' . link
|
||||
let link_exists_in_diary = filereadable(link_diary)
|
||||
let link_exists_in_wiki = filereadable(link_wiki)
|
||||
let link_is_date = a:lnk =~# '\d\d\d\d-\d\d-\d\d'
|
||||
@ -1900,7 +1900,7 @@ function! s:normalize_link_in_diary(lnk) " {{{
|
||||
let rxDesc = ''
|
||||
let template = g:vimwiki_WikiLinkTemplate1
|
||||
else
|
||||
let depth = len(split(VimwikiGet('diary_rel_path'), '/'))
|
||||
let depth = len(split(vimwiki#vars#get_wikilocal('diary_rel_path'), '/'))
|
||||
let str = repeat('../', depth) . a:lnk . '|' . a:lnk
|
||||
let rxUrl = '^.*\ze|'
|
||||
let rxDesc = '|\zs.*$'
|
||||
|
@ -20,23 +20,22 @@ function! s:prefix_zero(num) "{{{
|
||||
return a:num
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_date_link(fmt) "{{{
|
||||
return strftime(a:fmt)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:diary_path(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
|
||||
return VimwikiGet('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:diary_index(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return s:diary_path(idx).VimwikiGet('diary_index', idx).VimwikiGet('ext', idx)
|
||||
return s:diary_path(idx).vimwiki#vars#get_wikilocal('diary_index', idx).VimwikiGet('ext', idx)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:diary_date_link(...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
return s:get_date_link(VimwikiGet('diary_link_fmt', idx))
|
||||
function! vimwiki#diary#diary_date_link(...) "{{{
|
||||
if a:0
|
||||
return strftime('%Y-%m-%d', a:1)
|
||||
else
|
||||
return strftime('%Y-%m-%d')
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_position_links(link) "{{{
|
||||
@ -45,8 +44,8 @@ function! s:get_position_links(link) "{{{
|
||||
if a:link =~# '^\d\{4}-\d\d-\d\d'
|
||||
let links = keys(s:get_diary_links())
|
||||
" include 'today' into links
|
||||
if index(links, s:diary_date_link()) == -1
|
||||
call add(links, s:diary_date_link())
|
||||
if index(links, vimwiki#diary#diary_date_link()) == -1
|
||||
call add(links, vimwiki#diary#diary_date_link())
|
||||
endif
|
||||
call sort(links)
|
||||
let idx = index(links, a:link)
|
||||
@ -85,7 +84,7 @@ endfun "}}}
|
||||
|
||||
fun! s:get_diary_links() "{{{
|
||||
let rx = '^\d\{4}-\d\d-\d\d'
|
||||
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||
let s_files = glob(VimwikiGet('path').vimwiki#vars#get_wikilocal('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||
let files = split(s_files, '\n')
|
||||
call filter(files, 'fnamemodify(v:val, ":t") =~# "'.escape(rx, '\').'"')
|
||||
|
||||
@ -119,7 +118,7 @@ fun! s:group_links(links) "{{{
|
||||
endfun "}}}
|
||||
|
||||
function! s:sort(lst) "{{{
|
||||
if VimwikiGet("diary_sort") ==? 'desc'
|
||||
if vimwiki#vars#get_wikilocal('diary_sort') ==? 'desc'
|
||||
return reverse(sort(a:lst))
|
||||
else
|
||||
return sort(a:lst)
|
||||
@ -172,7 +171,7 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
let idx = 0
|
||||
endif
|
||||
|
||||
call vimwiki#path#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
|
||||
call vimwiki#path#mkdir(VimwikiGet('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx))
|
||||
|
||||
if a:0 && a:1 == 1
|
||||
let cmd = 'tabedit'
|
||||
@ -182,7 +181,7 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
if a:0>1
|
||||
let link = 'diary:'.a:2
|
||||
else
|
||||
let link = 'diary:'.s:diary_date_link(idx)
|
||||
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
||||
endif
|
||||
|
||||
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
|
||||
@ -218,7 +217,7 @@ function! vimwiki#diary#goto_next_day() "{{{
|
||||
let link = 'diary:'.links[idx+1]
|
||||
else
|
||||
" goto today
|
||||
let link = 'diary:'.s:diary_date_link()
|
||||
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
@ -238,7 +237,7 @@ function! vimwiki#diary#goto_prev_day() "{{{
|
||||
let link = 'diary:'.links[idx-1]
|
||||
else
|
||||
" goto today
|
||||
let link = 'diary:'.s:diary_date_link()
|
||||
let link = 'diary:'.vimwiki#diary#diary_date_link()
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
@ -252,7 +251,7 @@ function! vimwiki#diary#generate_diary_section() "{{{
|
||||
if vimwiki#path#is_equal(current_file, diary_file)
|
||||
let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.g:vimwiki_rxHeader.'\)'
|
||||
call vimwiki#base#update_listing_in_buffer(s:format_diary(),
|
||||
\ VimwikiGet('diary_header'), content_rx, line('$')+1, 1)
|
||||
\ vimwiki#vars#get_wikilocal('diary_header'), content_rx, line('$')+1, 1)
|
||||
else
|
||||
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
|
||||
endif
|
||||
@ -286,7 +285,7 @@ endfunction "}}}
|
||||
function vimwiki#diary#calendar_sign(day, month, year) "{{{
|
||||
let day = s:prefix_zero(a:day)
|
||||
let month = s:prefix_zero(a:month)
|
||||
let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
|
||||
let sfile = VimwikiGet('path').vimwiki#vars#get_wikilocal('diary_rel_path').
|
||||
\ a:year.'-'.month.'-'.day.VimwikiGet('ext')
|
||||
return filereadable(expand(sfile))
|
||||
endfunction "}}}
|
||||
|
@ -1348,13 +1348,13 @@ function! s:parse_line(line, state) " {{{
|
||||
endfunction " }}}
|
||||
|
||||
function! s:use_custom_wiki2html() "{{{
|
||||
let custom_wiki2html = VimwikiGet('custom_wiki2html')
|
||||
let custom_wiki2html = vimwiki#vars#get_wikilocal('custom_wiki2html')
|
||||
return !empty(custom_wiki2html) && (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html))
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
|
||||
call vimwiki#path#mkdir(a:path)
|
||||
echomsg system(VimwikiGet('custom_wiki2html'). ' '.
|
||||
echomsg system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '.
|
||||
\ a:force. ' '.
|
||||
\ VimwikiGet('syntax'). ' '.
|
||||
\ strpart(VimwikiGet('ext'), 1). ' '.
|
||||
|
@ -113,10 +113,11 @@ function! vimwiki#lst#default_symbol() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#lst#get_list_margin() "{{{
|
||||
if VimwikiGet('list_margin') < 0
|
||||
let list_margin = vimwiki#vars#get_wikilocal('list_margin')
|
||||
if list_margin < 0
|
||||
return &sw
|
||||
else
|
||||
return VimwikiGet('list_margin')
|
||||
return list_margin
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
|
@ -105,7 +105,6 @@ function! s:populate_wikilocal_options()
|
||||
\ 'custom_wiki2html': '',
|
||||
\ 'diary_header': 'Diary',
|
||||
\ 'diary_index': 'diary',
|
||||
\ 'diary_link_fmt': '%Y-%m-%d',
|
||||
\ 'diary_rel_path': 'diary/',
|
||||
\ 'diary_sort': 'desc',
|
||||
\ 'ext': '.wiki',
|
||||
@ -217,12 +216,18 @@ function! vimwiki#vars#get_global(key)
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#get_wikilocal(wiki_nr, key)
|
||||
return g:vimwiki_wikilocal_vars[a:wiki_nr][a:key]
|
||||
" the second argument can be a wiki number. When absent, the wiki of the currently active buffer is
|
||||
" used
|
||||
function! vimwiki#vars#get_wikilocal(key, ...)
|
||||
if a:0
|
||||
return g:vimwiki_wikilocal_vars[a:1][a:key]
|
||||
else
|
||||
return g:vimwiki_wikilocal_vars[vimwiki#vars#get_bufferlocal('wiki_nr')][a:key]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! vimwiki#vars#set_wikilocal(wiki_nr, key, value)
|
||||
function! vimwiki#vars#set_wikilocal(key, value, wiki_nr)
|
||||
if a:wiki_nr == len(g:vimwiki_wikilocal_vars) - 1
|
||||
call insert(g:vimwiki_wikilocal_vars, {}, -1)
|
||||
endif
|
||||
|
@ -655,7 +655,7 @@ if VimwikiGet('auto_toc')
|
||||
augroup END
|
||||
endif
|
||||
|
||||
if VimwikiGet('auto_tags')
|
||||
if vimwiki#vars#get_wikilocal('auto_tags')
|
||||
" Automatically update tags metadata on page write.
|
||||
augroup vimwiki
|
||||
au BufWritePost <buffer> call vimwiki#tags#update_tags(0, '')
|
||||
|
@ -44,8 +44,8 @@ function! Validate_wiki_options(idx) " {{{
|
||||
call VimwikiSet('path_html', s:normalize_path(s:path_html(a:idx)), a:idx)
|
||||
call VimwikiSet('template_path',
|
||||
\ s:normalize_path(VimwikiGet('template_path', a:idx)), a:idx)
|
||||
call VimwikiSet('diary_rel_path',
|
||||
\ s:normalize_path(VimwikiGet('diary_rel_path', a:idx)), a:idx)
|
||||
call vimwiki#vars#set_wikilocal('diary_rel_path',
|
||||
\ s:normalize_path(vimwiki#vars#get_wikilocal('diary_rel_path', a:idx)), a:idx)
|
||||
endfunction " }}}
|
||||
|
||||
function! s:vimwiki_idx() " {{{
|
||||
@ -339,23 +339,6 @@ let s:vimwiki_defaults.auto_toc = 0
|
||||
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
|
||||
" file.
|
||||
let s:vimwiki_defaults.temp = 0
|
||||
|
||||
" diary
|
||||
let s:vimwiki_defaults.diary_rel_path = 'diary/'
|
||||
let s:vimwiki_defaults.diary_index = 'diary'
|
||||
let s:vimwiki_defaults.diary_header = 'Diary'
|
||||
let s:vimwiki_defaults.diary_sort = 'desc'
|
||||
|
||||
" Do not change this! Will wait till vim become more datetime awareable.
|
||||
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
|
||||
|
||||
" NEW! in v2.0
|
||||
" custom_wiki2html
|
||||
let s:vimwiki_defaults.custom_wiki2html = ''
|
||||
"
|
||||
let s:vimwiki_defaults.list_margin = -1
|
||||
|
||||
let s:vimwiki_defaults.auto_tags = 0
|
||||
"}}}
|
||||
|
||||
" DEFAULT options {{{
|
||||
@ -409,7 +392,7 @@ command! -count=1 VimwikiMakeDiaryNote
|
||||
command! -count=1 VimwikiTabMakeDiaryNote
|
||||
\ call vimwiki#diary#make_note(v:count1, 1)
|
||||
command! -count=1 VimwikiMakeYesterdayDiaryNote
|
||||
\ call vimwiki#diary#make_note(v:count1, 0, strftime(VimwikiGet('diary_link_fmt', v:count1 - 1), localtime() - 60*60*24))
|
||||
\ call vimwiki#diary#make_note(v:count1, 0, vimwiki#diary#diary_date_link(localtime() - 60*60*24))
|
||||
|
||||
command! VimwikiDiaryGenerateLinks
|
||||
\ call vimwiki#diary#generate_diary_section()
|
||||
|
Loading…
Reference in New Issue
Block a user