diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 0d18377..2a68ac6 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -81,7 +81,7 @@ function! vimwiki#base#find_wiki(path) "{{{ return idx endif let idx += 1 - endwhile + endfor " an orphan page has been detected return -1 @@ -1128,7 +1128,7 @@ endfunction " }}} " vimwiki#base#go_back_link function! vimwiki#base#go_back_link() "{{{ let prev_link = vimwiki#vars#get_bufferlocal('prev_link') - if prev_link !=# '' + if !empty(prev_link) " go back to saved wiki link execute ":e ".substitute(prev_link[0], '\s', '\\\0', 'g') call setpos('.', prev_link[1]) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 72b946a..a6a1f63 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -559,7 +559,7 @@ function! s:process_tags_typefaces(line, header_ids) "{{{ let line = a:line let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxItalic'), 's:tag_em') let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxBold'), 's:tag_strong', a:header_ids) - let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxTodo'), 's:tag_todo') + let line = s:make_tag(line, vimwiki#vars#get_global('rxTodo'), 's:tag_todo') let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxDelText'), 's:tag_strike') let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxSuperScript'), 's:tag_super') let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxSubScript'), 's:tag_sub') diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim index f0ee7a3..a207f53 100644 --- a/autoload/vimwiki/markdown_base.vim +++ b/autoload/vimwiki/markdown_base.vim @@ -6,11 +6,6 @@ " MISC helper functions {{{ -" vimwiki#markdown_base#reset_mkd_refs -function! vimwiki#markdown_base#reset_mkd_refs() "{{{ - call vimwiki#vars#set_bufferlocal('markdown_refs', {}) -endfunction "}}} - " vimwiki#markdown_base#scan_reflinks function! vimwiki#markdown_base#scan_reflinks() " {{{ let mkd_refs = {} @@ -35,29 +30,12 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{ endfunction "}}} -" vimwiki#markdown_base#get_reflinks -function! vimwiki#markdown_base#get_reflinks() " {{{ - let done = 1 - try - let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs') - catch - " work-around hack - let done = 0 - " ... the following command does not work inside catch block !? - " > let mkd_refs = vimwiki#markdown_base#scan_reflinks() - endtry - if !done - let mkd_refs = vimwiki#markdown_base#scan_reflinks() - endif - return mkd_refs -endfunction "}}} - " vimwiki#markdown_base#open_reflink " try markdown reference links function! vimwiki#markdown_base#open_reflink(link) " {{{ " echom "vimwiki#markdown_base#open_reflink" let link = a:link - let mkd_refs = vimwiki#markdown_base#get_reflinks() + let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs') if has_key(mkd_refs, link) let url = mkd_refs[link] call vimwiki#base#system_open_link(url) diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index e4a6b72..c088106 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -383,7 +383,7 @@ function! s:populate_extra_markdown_vars() " 0b) match URL within [[URL|DESCRIPTION]] let mkd_syntax.rxWikiLink0MatchUrl = mkd_syntax.rxWikiLinkMatchUrl " 0c) match DESCRIPTION within [[URL|DESCRIPTION]] - let mkd_syntax.rxWikiLink0MatchDescr = g:vimwiki_global_vars.rxWikiLinkMatchDescr + let mkd_syntax.rxWikiLink0MatchDescr = mkd_syntax.rxWikiLinkMatchDescr let wikilink_md_prefix = '[' let wikilink_md_suffix = ']' @@ -423,25 +423,25 @@ function! s:populate_extra_markdown_vars() " 1. match [URL][], [DESCRIPTION][URL] let mkd_syntax.rxWikiLink1 = mkd_syntax.rx_wikilink_md_prefix. - \ mkd_syntax.rxWikiLink1Url. mkd_syntax.rx_wikilink_md_separator. + \ mkd_syntax.rxWikiLink1Url. rx_wikilink_md_separator. \ mkd_syntax.rx_wikilink_md_suffix. \ '\|'. mkd_syntax.rx_wikilink_md_prefix. - \ mkd_syntax.rxWikiLink1Descr . mkd_syntax.rx_wikilink_md_separator. + \ mkd_syntax.rxWikiLink1Descr . rx_wikilink_md_separator. \ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix " 2. match URL within [URL][], [DESCRIPTION][URL] let mkd_syntax.rxWikiLink1MatchUrl = mkd_syntax.rx_wikilink_md_prefix. - \ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. mkd_syntax.rx_wikilink_md_separator. + \ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. rx_wikilink_md_separator. \ mkd_syntax.rx_wikilink_md_suffix. \ '\|'. mkd_syntax.rx_wikilink_md_prefix. - \ mkd_syntax.rxWikiLink1Descr. mkd_syntax.rx_wikilink_md_separator. + \ mkd_syntax.rxWikiLink1Descr. rx_wikilink_md_separator. \ '\zs'. mkd_syntax.rxWikiLink1Url. '\ze'. mkd_syntax.rx_wikilink_md_suffix " 3. match DESCRIPTION within [DESCRIPTION][URL] let mkd_syntax.rxWikiLink1MatchDescr = mkd_syntax.rx_wikilink_md_prefix. - \ '\zs'. mkd_syntax.rxWikiLink1Descr.'\ze'. mkd_syntax.rx_wikilink_md_separator. + \ '\zs'. mkd_syntax.rxWikiLink1Descr.'\ze'. rx_wikilink_md_separator. \ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix let mkd_syntax.rxWikiLink1Prefix1 = mkd_syntax.rx_wikilink_md_prefix - let mkd_syntax.rxWikiLink1Suffix1 = mkd_syntax.rx_wikilink_md_separator. + let mkd_syntax.rxWikiLink1Suffix1 = rx_wikilink_md_separator. \ mkd_syntax.rxWikiLink1Url . mkd_syntax.rx_wikilink_md_suffix " 1. match ANY wikilink @@ -508,14 +508,14 @@ function! s:populate_extra_markdown_vars() \ mkd_syntax.rxWeblink1MatchDescr.'\|'. \ mkd_syntax.rxWeblinkMatchDescr0 - let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'. - \ g:vimwiki_rxWikiIncl.'\|'.mkd_syntax.rxWeblink + let mkd_syntax.rxAnyLink = mkd_syntax.rxWikiLink.'\|'. + \ g:vimwiki_global_vars.rxWikiIncl.'\|'.mkd_syntax.rxWeblink let mkd_syntax.rxMkdRef = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)'. \ mkd_syntax.rxWeblink0 - let g:vimwiki_rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_global_vars.rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'. + let mkd_syntax.rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_global_vars.rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'. \ mkd_syntax.rxWeblink0 - let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'. + let mkd_syntax.rxMkdRefMatchUrl = '\['.g:vimwiki_global_vars.rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'. \ mkd_syntax.rxWeblink0.'\ze' endfunction @@ -562,9 +562,13 @@ function! vimwiki#vars#get_bufferlocal(key, ...) call setbufvar(buffer, 'vimwiki_existing_wikidirs', \ vimwiki#base#get_wiki_directories(vimwiki#vars#get_bufferlocal('wiki_nr'))) elseif a:key ==# 'prev_link' - call setbufvar(buffer, 'vimwiki_prev_link', '') + call setbufvar(buffer, 'vimwiki_prev_link', []) elseif a:key ==# 'fs_rescan' call setbufvar(buffer, 'vimwiki_fs_rescan', 0) + elseif a:key ==# 'markdown_refs' + call setbufvar(buffer, 'vimwiki_markdown_refs', vimwiki#markdown_base#scan_reflinks()) + else + echoerr 'Vimwiki Error: unknown buffer variable ' . string(a:key) endif return getbufvar(buffer, 'vimwiki_'.a:key) diff --git a/syntax/vimwiki_markdown_custom.vim b/syntax/vimwiki_markdown_custom.vim index 7f3cc15..4f19b24 100644 --- a/syntax/vimwiki_markdown_custom.vim +++ b/syntax/vimwiki_markdown_custom.vim @@ -30,8 +30,7 @@ function! s:wrap_wikilink1_rx(target) "{{{ endfunction "}}} function! s:existing_mkd_refs() "{{{ - call vimwiki#markdown_base#reset_mkd_refs() - return keys(vimwiki#markdown_base#get_reflinks()) + return keys(vimwiki#markdown_base#scan_reflinks()) endfunction "}}} function! s:highlight_existing_links() "{{{ @@ -121,7 +120,7 @@ call s:add_target_syntax_ON(s:wrap_wikilink1_rx(s:target), 'VimwikiWikiLink1') " Header levels, 1-6 for s:i in range(1,6) - execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocalg('rxH'.s:i).'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell' + execute 'syntax match VimwikiHeader'.s:i.' /'.vimwiki#vars#get_syntaxlocal('rxH'.s:i).'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell' endfor " }}}