diff --git a/autoload/vimwiki/u.vim b/autoload/vimwiki/u.vim index bc10ba3..2c60bb2 100644 --- a/autoload/vimwiki/u.vim +++ b/autoload/vimwiki/u.vim @@ -78,3 +78,13 @@ endfunction "}}} function! vimwiki#u#escape(string) "{{{ return escape(a:string, '.*[]\^$') endfunction "}}} + +" Load concrete Wiki syntax: sets regexes and templates for headers and links +function vimwiki#u#reload_regexes() "{{{ + execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim' +endfunction "}}} + +" Load syntax-specific functionality +function vimwiki#u#reload_regexes_custom() "{{{ + execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim' +endfunction "}}} diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index b9df7fe..30895d7 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -7,7 +7,8 @@ if exists("b:did_ftplugin") finish endif let b:did_ftplugin = 1 " Don't load another plugin for this buffer -execute 'runtime! syntax/vimwiki.vim' + +call vimwiki#u#reload_regexes() " UNDO list {{{ " Reset the following options to undo this plugin. diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim index 239f5ca..50f1312 100644 --- a/syntax/vimwiki.vim +++ b/syntax/vimwiki.vim @@ -9,6 +9,7 @@ if version < 600 elseif exists("b:current_syntax") finish endif + "TODO do nothing if ...? (?) let starttime = reltime() " start the clock if VimwikiGet('maxhi') @@ -43,10 +44,8 @@ let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols . " }}} -" ------------------------------------------------------------------------- -" Load concrete Wiki syntax: sets regexes and templates for headers and links -execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim' -" ------------------------------------------------------------------------- +call vimwiki#u#reload_regexes() + let time0 = vimwiki#u#time(starttime) "XXX " LINKS: setup of larger regexes {{{ @@ -399,10 +398,7 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/ syntax match VimwikiCellSeparator \ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained -" List items -let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' -let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.join(g:vimwiki_listsyms, '').']\)\]\s\)\?' - +" Lists execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/' execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/' execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/' @@ -577,10 +573,8 @@ hi def link VimwikiLinkCharT VimwikiLinkT hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT "}}} -" ------------------------------------------------------------------------- " Load syntax-specific functionality -execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim' -" ------------------------------------------------------------------------- +call vimwiki#u#reload_regexes_custom() " FIXME it now does not make sense to pretend there is a single syntax "vimwiki" let b:current_syntax="vimwiki" diff --git a/syntax/vimwiki_default.vim b/syntax/vimwiki_default.vim index 6b8a591..00af626 100644 --- a/syntax/vimwiki_default.vim +++ b/syntax/vimwiki_default.vim @@ -80,8 +80,10 @@ let g:vimwiki_number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)'] "it is used for i_ among other things let g:vimwiki_list_markers = ['-', '•', '1.', '*', 'I)', 'a)'] let g:vimwiki_rxListDefine = '::\(\s\|$\)' - call vimwiki#lst#setup_marker_infos() + +let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' +let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.join(g:vimwiki_listsyms, '').']\)\]\s\)\?' let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' " Preformatted text diff --git a/syntax/vimwiki_markdown.vim b/syntax/vimwiki_markdown.vim index 0291655..652b05c 100644 --- a/syntax/vimwiki_markdown.vim +++ b/syntax/vimwiki_markdown.vim @@ -78,6 +78,9 @@ let g:vimwiki_number_types = ['1.'] let g:vimwiki_list_markers = ['-', '*', '+', '1.'] let g:vimwiki_rxListDefine = '::\%(\s\|$\)' call vimwiki#lst#setup_marker_infos() + +let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' +let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.join(g:vimwiki_listsyms, '').']\)\]\s\)\?' let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' " Preformatted text diff --git a/syntax/vimwiki_media.vim b/syntax/vimwiki_media.vim index 12a0656..d11626e 100644 --- a/syntax/vimwiki_media.vim +++ b/syntax/vimwiki_media.vim @@ -59,7 +59,10 @@ let g:vimwiki_number_types = [] let g:vimwiki_list_markers = ['*', '#'] let g:vimwiki_rxListDefine = '^\%(;\|:\)\s' call vimwiki#lst#setup_marker_infos() -let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|^\s.*\)\)*' + +let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s' +let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.join(g:vimwiki_listsyms, '').']\)\]\s\)\?' +let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' " Preformatted text let g:vimwiki_rxPreStart = '
'