:VimwikiBacklinks now considers subdirs and other wikis

This commit is contained in:
EinfachToll 2014-12-07 11:59:56 +01:00
parent 53ecfdcc68
commit f419b04346

View File

@ -524,11 +524,29 @@ endfunction "}}}
" vimwiki#base#backlinks " vimwiki#base#backlinks
function! vimwiki#base#backlinks() "{{{ function! vimwiki#base#backlinks() "{{{
let filename = expand("%:t:r") let current_filename = expand("%:p")
let rx_wikilink = vimwiki#base#apply_template( let locations = []
\ g:vimwiki_WikiLinkMatchUrlTemplate, filename, '', '') for idx in range(len(g:vimwiki_list))
execute 'lvimgrep "\C'.rx_wikilink.'" '. let syntax = VimwikiGet('syntax', idx)
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') let wikifiles = s:find_files(idx, 0)
for source_file in wikifiles
let links = s:get_links(source_file, idx)
for [target_file, _, lnum, col] in links
" echom source_file target_file
" don't include links from the current file to itself
if target_file == current_filename && target_file != source_file
call add(locations, {'filename':source_file, 'lnum':lnum, 'col':col})
endif
endfor
endfor
endfor
if empty(locations)
echom 'vimwiki: no other file links to this file'
else
call setloclist(0, locations, 'r')
lopen
endif
endfunction "}}} endfunction "}}}
" Returns: a list containing all files of the given wiki as absolute file path. " Returns: a list containing all files of the given wiki as absolute file path.