diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 2d9ad96..8875e0b 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -253,7 +253,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{ let link_text = a:link_text " if link is schemeless add wikiN: scheme - if link_text !~# g:vimwiki_rxSchemeUrl + if link_text !~# vimwiki#vars#get_global('rxSchemeUrl') let link_text = 'wiki'.source_wiki.':'.link_text endif @@ -267,7 +267,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{ " extract scheme - let link_infos.scheme = matchstr(link_text, g:vimwiki_rxSchemeUrlMatchScheme) + let link_infos.scheme = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchScheme')) if link_infos.scheme == '' || link_text == '' let link_infos.filename = '' " malformed link return link_infos @@ -276,7 +276,7 @@ function! vimwiki#base#resolve_link(link_text, ...) "{{{ let link_infos.filename = link_text " unknown scheme, may be a weblink return link_infos endif - let link_text = matchstr(link_text, g:vimwiki_rxSchemeUrlMatchUrl) + let link_text = matchstr(link_text, vimwiki#vars#get_global('rxSchemeUrlMatchUrl')) let is_wiki_link = link_infos.scheme =~# '\mwiki\d\+' || \ link_infos.scheme ==# 'diary' diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index d2d81b9..10081b5 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -1417,8 +1417,8 @@ function! s:convert_file(path_html, wikifile) "{{{ " prepare constants for s:safe_html_line() let s:lt_pattern = '<' let s:gt_pattern = '>' - if g:vimwiki_valid_html_tags != '' - let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|') + if vimwiki#vars#get_global('valid_html_tags') != '' + let tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|') let s:lt_pattern = '\c<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!' let s:gt_pattern = '\c\%(' endif diff --git a/autoload/vimwiki/path.vim b/autoload/vimwiki/path.vim index f57c6fb..ffa48c3 100644 --- a/autoload/vimwiki/path.vim +++ b/autoload/vimwiki/path.vim @@ -127,8 +127,8 @@ function! vimwiki#path#mkdir(path, ...) "{{{ endif let path = vimwiki#path#chomp_slash(path) - if vimwiki#u#is_windows() && !empty(g:vimwiki_w32_dir_enc) - let path = iconv(path, &enc, g:vimwiki_w32_dir_enc) + if vimwiki#u#is_windows() && !empty(vimwiki#vars#get_global('w32_dir_enc')) + let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc')) endif if a:0 && a:1 && input("Vimwiki: Make new directory: " diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index f7ccdb8..fd04ca2 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -47,6 +47,39 @@ function! s:populate_global_variables() let g:vimwiki_global_vars[key] = g:vimwiki_{key} endif endfor + + " non-configurable global variables + + " Scheme regexes should be defined even if syntax file is not loaded yet cause users should be + " able to ww without opening any vimwiki file first + let g:vimwiki_global_vars['schemes'] = 'wiki\d\+,diary,local' + let g:vimwiki_global_vars['web_schemes1'] = 'http,https,file,ftp,gopher,telnet,nntp,ldap,rsync'. + \ ',imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp' + let web_schemes2 = 'mailto,news,xmpp,sip,sips,doi,urn,tel' + + let rx_schemes = '\%('. + \ join(split(g:vimwiki_global_vars['schemes'], '\s*,\s*'), '\|').'\|'. + \ join(split(g:vimwiki_global_vars['web_schemes1'], '\s*,\s*'), '\|').'\|'. + \ join(split(web_schemes2, '\s*,\s*'), '\|'). + \ '\)' + + let g:vimwiki_global_vars['rxSchemeUrl'] = rx_schemes.':.*' + let g:vimwiki_global_vars['rxSchemeUrlMatchScheme'] = '\zs'.rx_schemes.'\ze:.*' + let g:vimwiki_global_vars['rxSchemeUrlMatchUrl'] = rx_schemes.':\zs.*\ze' + + " match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme + " http://tools.ietf.org/html/rfc3986 + let rxWebProtocols = + \ '\%('. + \ '\%('. + \ '\%('.join(split(g:vimwiki_global_vars['web_schemes1'], '\s*,\s*'), '\|').'\):'. + \ '\%(//\)'. + \ '\)'. + \ '\|'. + \ '\%('.join(split(web_schemes2, '\s*,\s*'), '\|').'\):'. + \ '\)' + + let g:vimwiki_global_vars['rxWeblinkUrl'] = rxWebProtocols . '\S\{-1,}'. '\%(([^ \t()]*)\)\=' endfunction diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 4312f20..e12b5fd 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -363,26 +363,6 @@ call s:default('list', [s:vimwiki_defaults]) call s:default('current_idx', 0) -" Scheme regexes should be defined even if syntax file is not loaded yet -" cause users should be able to ww without opening any -" vimwiki file first -" Scheme regexes {{{ -call s:default('schemes', 'wiki\d\+,diary,local') -call s:default('web_schemes1', 'http,https,file,ftp,gopher,telnet,nntp,ldap,'. - \ 'rsync,imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp') -call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel') - -let s:rxSchemes = '\%('. - \ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'. - \ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'. - \ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|'). - \ '\)' - -call s:default('rxSchemeUrl', s:rxSchemes.':.*') -call s:default('rxSchemeUrlMatchScheme', '\zs'.s:rxSchemes.'\ze:.*') -call s:default('rxSchemeUrlMatchUrl', s:rxSchemes.':\zs.*\ze') -" scheme regexes }}} - for s:idx in range(len(g:vimwiki_list)) call Validate_wiki_options(s:idx) endfor diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim index f0c8a9c..8184e9e 100644 --- a/syntax/vimwiki.vim +++ b/syntax/vimwiki.vim @@ -22,27 +22,6 @@ endif " ... "endif -" LINKS: assume this is common to all syntaxes "{{{ - -" LINKS: WebLinks {{{ -" match URL for common protocols; -" see http://en.wikipedia.org/wiki/URI_scheme http://tools.ietf.org/html/rfc3986 -let g:vimwiki_rxWebProtocols = ''. - \ '\%('. - \ '\%('. - \ '\%('.join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\):'. - \ '\%(//\)'. - \ '\)'. - \ '\|'. - \ '\%('.join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').'\):'. - \ '\)' -" -let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols . - \ '\S\{-1,}'. '\%(([^ \t()]*)\)\=' -" }}} - -" }}} - call vimwiki#u#reload_regexes() " LINKS: setup of larger regexes {{{ @@ -155,7 +134,7 @@ let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs. " the whitespace. " Stuart, could you check it with markdown templated links? [](http://...), as " the last bracket is the part of URL now? -let g:vimwiki_rxWeblink = '\<'. g:vimwiki_rxWeblinkUrl . '\S*' +let g:vimwiki_rxWeblink = '\<'. vimwiki#vars#get_global('rxWeblinkUrl') . '\S*' " 0a) match URL within URL let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink " 0b) match DESCRIPTION within URL @@ -256,8 +235,8 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink') " WikiLink " All remaining schemes are highlighted automatically let s:rxSchemes = '\%('. - \ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'. - \ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|'). + \ join(split(vimwiki#vars#get_global('schemes'), '\s*,\s*'), '\|').'\|'. + \ join(split(vimwiki#vars#get_global('web_schemes1'), '\s*,\s*'), '\|'). \ '\):' " a) match [[nonwiki-scheme-URL]] diff --git a/syntax/vimwiki_markdown_custom.vim b/syntax/vimwiki_markdown_custom.vim index db39421..2c77515 100644 --- a/syntax/vimwiki_markdown_custom.vim +++ b/syntax/vimwiki_markdown_custom.vim @@ -297,8 +297,8 @@ call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1') " WikiLink " All remaining schemes are highlighted automatically let s:rxSchemes = '\%('. - \ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'. - \ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|'). + \ join(split(vimwiki#vars#get_global('schemes'), '\s*,\s*'), '\|').'\|'. + \ join(split(vimwiki#vars#get_global('web_schemes1'), '\s*,\s*'), '\|'). \ '\):' " a) match [nonwiki-scheme-URL]