Generate links when diary & wiki dir are the same

When generating links, we first check that the file is not a diary file
as we don't want to include those in the list. That work is delegated to
the `is_diary_file` function. Prior to this change, the function always
returned true if the file was in the diary directory.
This approach gives false positives for a wiki which has a flat structure
and the wiki files and diary files share a directory. eg:

let wiki.diary_rel_path = './'

This change reuses existing diary functions from the diary.vim module to
get an exact list of diary files to check against.
This commit is contained in:
Patrick Stockwell
2020-05-09 10:45:32 +10:00
committed by Tinmarino
parent 1020ac51bf
commit b96e82d6cc
3 changed files with 16 additions and 13 deletions

View File

@@ -20,12 +20,11 @@ else
endfunction
endif
" collapse sections like /a/b/../c to /a/c
" collapse sections like /a/b/../c to /a/c and /a/b/./c to /a/b/c
function! vimwiki#path#normalize(path) abort
let path = a:path
while 1
let result = substitute(path, '/[^/]\+/\.\.', '', '')
let result = substitute(path, '/[^/]\+/\.\.\|\./', '', '')
if result ==# path
break
endif