This commit is contained in:
Tinmarino 2020-07-21 19:37:05 -04:00
parent 068a26acec
commit 8cf2789840

View File

@ -1364,35 +1364,33 @@ function! vimwiki#base#follow_link(split, ...) abort
" Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the " Parse link at cursor and pass to VimwikiLinkHandler, or failing that, the
" default open_link handler " default open_link handler
" try WikiLink " Try WikiLink
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink')), let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink')),
\ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl')) \ vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl'))
" try WikiIncl " Try WikiIncl
if lnk ==? '' if lnk ==? ''
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')), let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')),
\ vimwiki#vars#get_global('rxWikiInclMatchUrl')) \ vimwiki#vars#get_global('rxWikiInclMatchUrl'))
endif endif
" try Weblink " Try Weblink
if lnk ==? '' if lnk ==? ''
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink')), let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWeblink')),
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl')) \ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
endif endif
" Try markdown image ![]()
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' && lnk ==# ''
" markdown image ![]() let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxImage')),
if lnk ==# '' \ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl'))
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxImage')), if lnk !=# ''
\ vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl')) if lnk !~# '\%(\%('.vimwiki#vars#get_global('web_schemes1').'\):\%(\/\/\)\?\)\S\{-1,}'
if lnk !=# '' " prepend file: scheme so link is opened by sytem handler if it isn't a web url
if lnk !~# '\%(\%('.vimwiki#vars#get_global('web_schemes1').'\):\%(\/\/\)\?\)\S\{-1,}' let lnk = 'file:'.lnk
" prepend file: scheme so link is opened by sytem handler if it isn't a web url
let lnk = 'file:'.lnk
endif
endif endif
endif endif
endif endif
if lnk !=? '' " cursor is indeed on a link " If cursor is indeed on a link
if lnk !=? ''
let processed_by_user_defined_handler = VimwikiLinkHandler(lnk) let processed_by_user_defined_handler = VimwikiLinkHandler(lnk)
if processed_by_user_defined_handler if processed_by_user_defined_handler
return return
@ -1438,7 +1436,8 @@ function! vimwiki#base#follow_link(split, ...) abort
endif endif
endif endif
else " cursor is not on a link " Else cursor is not on a link
else
if a:0 >= 3 if a:0 >= 3
execute 'normal! '.a:3 execute 'normal! '.a:3
elseif vimwiki#vars#get_global('create_link') elseif vimwiki#vars#get_global('create_link')
@ -2256,7 +2255,7 @@ endfunction
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) abort function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) abort
let url = matchstr(a:str, a:rxUrl) let url = matchstr(a:str, a:rxUrl)
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' && vimwiki#vars#get_global('markdown_link_ext') if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' && vimwiki#vars#get_global('markdown_link_ext')
" strip the extension if it exists so it doesn't get added multiple times " Strip the extension if it exists so it doesn't get added multiple times
let url = substitute(url, '\'.vimwiki#vars#get_wikilocal('ext').'$', '', '') let url = substitute(url, '\'.vimwiki#vars#get_wikilocal('ext').'$', '', '')
endif endif
let descr = matchstr(a:str, a:rxDesc) let descr = matchstr(a:str, a:rxDesc)