From f419b04346289f286d18f77921af8f76f31799a3 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Sun, 7 Dec 2014 11:59:56 +0100 Subject: [PATCH] :VimwikiBacklinks now considers subdirs and other wikis --- autoload/vimwiki/base.vim | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 7fa047e..e89f5ea 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -524,11 +524,29 @@ endfunction "}}} " vimwiki#base#backlinks function! vimwiki#base#backlinks() "{{{ - let filename = expand("%:t:r") - let rx_wikilink = vimwiki#base#apply_template( - \ g:vimwiki_WikiLinkMatchUrlTemplate, filename, '', '') - execute 'lvimgrep "\C'.rx_wikilink.'" '. - \ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ') + let current_filename = expand("%:p") + let locations = [] + for idx in range(len(g:vimwiki_list)) + let syntax = VimwikiGet('syntax', idx) + 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 "}}} " Returns: a list containing all files of the given wiki as absolute file path.