Implement :VimwikiRebuildTags to rebuild metadata for all pages in current wiki
This commit is contained in:
parent
4f639cebee
commit
df91772d7e
@ -1945,10 +1945,8 @@ let s:TAGS_METADATA_FILE_NAME = '.tags'
|
|||||||
" a:full_rebuild == 1: re-scan entire wiki
|
" a:full_rebuild == 1: re-scan entire wiki
|
||||||
" a:full_rebuild == 0: only re-scan current page
|
" a:full_rebuild == 0: only re-scan current page
|
||||||
function! vimwiki#base#update_tags(full_rebuild) "{{{
|
function! vimwiki#base#update_tags(full_rebuild) "{{{
|
||||||
if a:full_rebuild
|
if !a:full_rebuild
|
||||||
throw 'vimwiki#base#update_tags1: full rebuild not supported yet'
|
" Updating for one page (current)
|
||||||
endif
|
|
||||||
"
|
|
||||||
let page_name = expand('%:t:r')
|
let page_name = expand('%:t:r')
|
||||||
" Collect tags in current file
|
" Collect tags in current file
|
||||||
let tags = vimwiki#base#scan_tags(getline(1, '$'), page_name)
|
let tags = vimwiki#base#scan_tags(getline(1, '$'), page_name)
|
||||||
@ -1960,6 +1958,16 @@ function! vimwiki#base#update_tags(full_rebuild) "{{{
|
|||||||
let metadata = vimwiki#base#merge_tags(metadata, tags)
|
let metadata = vimwiki#base#merge_tags(metadata, tags)
|
||||||
" Save
|
" Save
|
||||||
call vimwiki#base#write_tags_metadata(metadata)
|
call vimwiki#base#write_tags_metadata(metadata)
|
||||||
|
else " full rebuild
|
||||||
|
let files = s:find_files(g:vimwiki_current_idx, 0)
|
||||||
|
let metadata = []
|
||||||
|
for file in files
|
||||||
|
let page_name = fnamemodify(file, ':t:r')
|
||||||
|
let tags = vimwiki#base#scan_tags(readfile(file), page_name)
|
||||||
|
let metadata = vimwiki#base#merge_tags(metadata, tags)
|
||||||
|
endfor
|
||||||
|
call vimwiki#base#write_tags_metadata(metadata)
|
||||||
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
" vimwiki#base#scan_tags
|
" vimwiki#base#scan_tags
|
||||||
|
@ -704,6 +704,10 @@ il A single list item.
|
|||||||
files are reachable from the index file. Errors are shown in the quickfix
|
files are reachable from the index file. Errors are shown in the quickfix
|
||||||
window.
|
window.
|
||||||
|
|
||||||
|
*:VimwikiRebuildTags*
|
||||||
|
Iterates over all files in a current wiki and rebuilds tags metadata (to
|
||||||
|
enable tags related commands).
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. Wiki syntax *vimwiki-syntax*
|
5. Wiki syntax *vimwiki-syntax*
|
||||||
|
|
||||||
|
@ -302,6 +302,9 @@ command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right(
|
|||||||
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
|
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
|
||||||
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
||||||
|
|
||||||
|
" tags commands
|
||||||
|
command! -buffer VimwikiRebuildTags call vimwiki#base#update_tags(1)
|
||||||
|
|
||||||
" COMMANDS }}}
|
" COMMANDS }}}
|
||||||
|
|
||||||
" KEYBINDINGS {{{
|
" KEYBINDINGS {{{
|
||||||
|
Loading…
Reference in New Issue
Block a user