parent
c0ead893b4
commit
4a04fc7519
@ -581,10 +581,8 @@ endfunction "}}}
|
||||
" vimwiki#base#backlinks
|
||||
function! vimwiki#base#backlinks() "{{{
|
||||
let filename = expand("%:t:r")
|
||||
let rx_wikilink = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
|
||||
\ '\zs'.filename.'\ze\%(#.*\)\?', '.*', '').
|
||||
\ '\|'. vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
|
||||
\ '\zs'.filename.'\ze\%(#.*\)\?', '.*', '')
|
||||
let rx_wikilink = vimwiki#base#apply_template(
|
||||
\ g:vimwiki_WikiLinkMatchUrlTemplate, filename, '', '')
|
||||
execute 'lvimgrep "\C'.rx_wikilink.'" '.
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
endfunction "}}}
|
||||
@ -821,17 +819,13 @@ endfunction " }}}
|
||||
function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
||||
let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g')
|
||||
let new_fname = a:new_fname
|
||||
let old_fname_r = old_fname
|
||||
let new_fname_r = new_fname
|
||||
|
||||
let old_fname_r = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
|
||||
\ '\zs'.old_fname.'\ze\%(#.*\)\?', '.*', '').
|
||||
\ '\|'. vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
|
||||
\ '\zs'.old_fname.'\ze\%(#.*\)\?', '.*', '')
|
||||
let old_fname_r = vimwiki#base#apply_template(
|
||||
\ g:vimwiki_WikiLinkMatchUrlTemplate, old_fname, '', '')
|
||||
|
||||
let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
|
||||
for fname in files
|
||||
call s:update_wiki_link(fname, old_fname_r, new_fname_r)
|
||||
call s:update_wiki_link(fname, old_fname_r, new_fname)
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
@ -1587,15 +1581,15 @@ endfunction
|
||||
" arguments rxUrl, rxDesc, and rxStyle are copied verbatim, without any
|
||||
" special character escapes or substitutions.
|
||||
function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
|
||||
let lnk = vimwiki#u#escape(a:template)
|
||||
let lnk = a:template
|
||||
if a:rxUrl != ""
|
||||
let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", '')
|
||||
let lnk = substitute(lnk, '__LinkUrl__', '\='."'".a:rxUrl."'", 'g')
|
||||
endif
|
||||
if a:rxDesc != ""
|
||||
let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", '')
|
||||
let lnk = substitute(lnk, '__LinkDescription__', '\='."'".a:rxDesc."'", 'g')
|
||||
endif
|
||||
if a:rxStyle != ""
|
||||
let lnk = substitute(lnk, '__LinkStyle__', '\='."'".a:rxStyle."'", '')
|
||||
let lnk = substitute(lnk, '__LinkStyle__', '\='."'".a:rxStyle."'", 'g')
|
||||
endif
|
||||
return lnk
|
||||
endfunction " }}}
|
||||
|
@ -51,22 +51,30 @@ let s:time0 = vimwiki#u#time(g:starttime) "XXX
|
||||
" LINKS: setup of larger regexes {{{
|
||||
|
||||
" LINKS: setup wikilink regexps {{{
|
||||
let g:vimwiki_rxWikiLinkPrefix = '[['
|
||||
let g:vimwiki_rxWikiLinkSuffix = ']]'
|
||||
let g:vimwiki_rxWikiLinkPrefix = '\[\['
|
||||
let g:vimwiki_rxWikiLinkSuffix = '\]\]'
|
||||
let g:vimwiki_rxWikiLinkSeparator = '|'
|
||||
" [[URL]]
|
||||
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
|
||||
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiLinkSuffix
|
||||
" [[URL|DESCRIPTION]]
|
||||
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
|
||||
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'.
|
||||
\ g:vimwiki_rxWikiLinkSuffix
|
||||
"
|
||||
let s:valid_chars = '[^\\\]]'
|
||||
|
||||
let g:vimwiki_rxWikiLinkPrefix = vimwiki#u#escape(g:vimwiki_rxWikiLinkPrefix)
|
||||
let g:vimwiki_rxWikiLinkSuffix = vimwiki#u#escape(g:vimwiki_rxWikiLinkSuffix)
|
||||
let g:vimwiki_rxWikiLinkSeparator = vimwiki#u#escape(g:vimwiki_rxWikiLinkSeparator)
|
||||
" match every Wikilink with a given URL
|
||||
let g:vimwiki_WikiLinkMatchUrlTemplate =
|
||||
\ g:vimwiki_rxWikiLinkPrefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ g:vimwiki_rxWikiLinkSuffix .
|
||||
\ '\|' .
|
||||
\ g:vimwiki_rxWikiLinkPrefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ g:vimwiki_rxWikiLinkSeparator .
|
||||
\ '.*' .
|
||||
\ g:vimwiki_rxWikiLinkSuffix
|
||||
|
||||
let s:valid_chars = '[^\\\]]'
|
||||
let g:vimwiki_rxWikiLinkUrl = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLinkDescr = s:valid_chars.'\{-}'
|
||||
|
||||
@ -108,11 +116,8 @@ let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
|
||||
\ '__LinkDescription__'.
|
||||
\ g:vimwiki_rxWikiInclSuffix
|
||||
|
||||
let s:valid_chars = '[^\\\}]'
|
||||
|
||||
let g:vimwiki_rxWikiInclPrefix = vimwiki#u#escape(g:vimwiki_rxWikiInclPrefix)
|
||||
let g:vimwiki_rxWikiInclSuffix = vimwiki#u#escape(g:vimwiki_rxWikiInclSuffix)
|
||||
let g:vimwiki_rxWikiInclSeparator = vimwiki#u#escape(g:vimwiki_rxWikiInclSeparator)
|
||||
let s:valid_chars = '[^\\\}]'
|
||||
let g:vimwiki_rxWikiInclUrl = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiInclArg = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg. '\)'.'\{-}'
|
||||
|
@ -30,9 +30,9 @@ let g:vimwiki_rxWikiLink0MatchDescr = g:vimwiki_rxWikiLinkMatchDescr
|
||||
" LINKS: setup wikilink1 regexps {{{
|
||||
" 1. [URL][], or [DESCRIPTION][URL]
|
||||
|
||||
let g:vimwiki_rxWikiLink1Prefix = '['
|
||||
let g:vimwiki_rxWikiLink1Suffix = ']'
|
||||
let g:vimwiki_rxWikiLink1Separator = ']['
|
||||
let g:vimwiki_rxWikiLink1Prefix = '\['
|
||||
let g:vimwiki_rxWikiLink1Suffix = '\]'
|
||||
let g:vimwiki_rxWikiLink1Separator = '\]\['
|
||||
|
||||
" [URL][]
|
||||
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
|
||||
@ -42,11 +42,20 @@ let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescript
|
||||
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
|
||||
\ g:vimwiki_rxWikiLink1Suffix
|
||||
"
|
||||
let s:valid_chars = '[^\\\[\]]'
|
||||
let g:vimwiki_WikiLinkMatchUrlTemplate .=
|
||||
\ '\|' .
|
||||
\ g:vimwiki_rxWikiLink1Prefix .
|
||||
\ '.*' .
|
||||
\ g:vimwiki_rxWikiLink1Separator .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ g:vimwiki_rxWikiLink1Suffix .
|
||||
\ '\|' .
|
||||
\ g:vimwiki_rxWikiLink1Prefix .
|
||||
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
|
||||
\ g:vimwiki_rxWikiLink1Separator .
|
||||
\ g:vimwiki_rxWikiLink1Suffix
|
||||
|
||||
let g:vimwiki_rxWikiLink1Prefix = vimwiki#u#escape(g:vimwiki_rxWikiLink1Prefix)
|
||||
let g:vimwiki_rxWikiLink1Suffix = vimwiki#u#escape(g:vimwiki_rxWikiLink1Suffix)
|
||||
let g:vimwiki_rxWikiLink1Separator = vimwiki#u#escape(g:vimwiki_rxWikiLink1Separator)
|
||||
let s:valid_chars = '[^\\\[\]]'
|
||||
let g:vimwiki_rxWikiLink1Url = s:valid_chars.'\{-}'
|
||||
let g:vimwiki_rxWikiLink1Descr = s:valid_chars.'\{-}'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user