:VimwikiGenerateTags
This commit is contained in:
parent
a62bebceb2
commit
e44b188a49
@ -2105,6 +2105,39 @@ function! vimwiki#base#get_tags(metadata) "{{{
|
|||||||
return keys(tags)
|
return keys(tags)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
|
" vimwiki#base#generate_tags
|
||||||
|
" Similar to vimwiki#base#generate_links. In the current buffer, appends
|
||||||
|
" tags and references to all their instances. If no arguments (tags) are
|
||||||
|
" specified, outputs all tags.
|
||||||
|
function! vimwiki#base#generate_tags(...) abort "{{{
|
||||||
|
let need_all_tags = (a:0 == 0)
|
||||||
|
let specific_tags = a:000
|
||||||
|
|
||||||
|
let metadata = vimwiki#base#load_tags_metadata()
|
||||||
|
|
||||||
|
call append(line('$'), [
|
||||||
|
\ '',
|
||||||
|
\ substitute(g:vimwiki_rxH1_Template, '__Header__', 'Generated Tags', '') ])
|
||||||
|
|
||||||
|
call sort(metadata)
|
||||||
|
|
||||||
|
let bullet = repeat(' ', vimwiki#lst#get_list_margin()).
|
||||||
|
\ vimwiki#lst#default_symbol().' '
|
||||||
|
let current_tag = ''
|
||||||
|
for entry in metadata
|
||||||
|
if need_all_tags || index(specific_tags, entry.tagname) != -1
|
||||||
|
if entry.tagname != current_tag
|
||||||
|
let current_tag = entry.tagname
|
||||||
|
call append(line('$'), [
|
||||||
|
\ '',
|
||||||
|
\ substitute(g:vimwiki_rxH2_Template, '__Header__', entry.tagname, ''),
|
||||||
|
\ '' ])
|
||||||
|
endif
|
||||||
|
call append(line('$'), bullet . '[[' . entry.link . ']]')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction " }}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Command completion functions {{{
|
" Command completion functions {{{
|
||||||
|
@ -712,6 +712,11 @@ il A single list item.
|
|||||||
Searches over the pages in current wiki and finds all locations of a given
|
Searches over the pages in current wiki and finds all locations of a given
|
||||||
tag. Supports |cmdline-completion|.
|
tag. Supports |cmdline-completion|.
|
||||||
|
|
||||||
|
*:VimwikiGenerateTags*
|
||||||
|
Similar to |:VimwikiGenerateLinks|. In the current buffer, appends tags
|
||||||
|
and references to all their instances. Supports |cmdline-completion|. If
|
||||||
|
no arguments (tags) are specified, outputs all tags.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. Wiki syntax *vimwiki-syntax*
|
5. Wiki syntax *vimwiki-syntax*
|
||||||
|
|
||||||
|
@ -306,6 +306,8 @@ command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
|
|||||||
command! -buffer VimwikiRebuildTags call vimwiki#base#update_tags(1)
|
command! -buffer VimwikiRebuildTags call vimwiki#base#update_tags(1)
|
||||||
command! -buffer -nargs=* -complete=custom,vimwiki#base#complete_tags
|
command! -buffer -nargs=* -complete=custom,vimwiki#base#complete_tags
|
||||||
\ VimwikiSearchTags VimwikiSearch /:<args>:/
|
\ VimwikiSearchTags VimwikiSearch /:<args>:/
|
||||||
|
command! -buffer -nargs=* -complete=custom,vimwiki#base#complete_tags
|
||||||
|
\ VimwikiGenerateTags call vimwiki#base#generate_tags(<f-args>)
|
||||||
|
|
||||||
" COMMANDS }}}
|
" COMMANDS }}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user