Do not load whole syntax file for a buffer twice.

Load twice only regexes for a concrete syntax.
This commit is contained in:
Maxim Kim 2013-07-18 09:55:24 +04:00
parent 79b78dc9ee
commit 58e072fa92
6 changed files with 27 additions and 14 deletions

View File

@ -78,3 +78,13 @@ endfunction "}}}
function! vimwiki#u#escape(string) "{{{ function! vimwiki#u#escape(string) "{{{
return escape(a:string, '.*[]\^$') return escape(a:string, '.*[]\^$')
endfunction "}}} 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 "}}}

View File

@ -7,7 +7,8 @@ if exists("b:did_ftplugin")
finish finish
endif endif
let b:did_ftplugin = 1 " Don't load another plugin for this buffer 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 {{{ " UNDO list {{{
" Reset the following options to undo this plugin. " Reset the following options to undo this plugin.

View File

@ -9,6 +9,7 @@ if version < 600
elseif exists("b:current_syntax") elseif exists("b:current_syntax")
finish finish
endif endif
"TODO do nothing if ...? (?) "TODO do nothing if ...? (?)
let starttime = reltime() " start the clock let starttime = reltime() " start the clock
if VimwikiGet('maxhi') if VimwikiGet('maxhi')
@ -43,10 +44,8 @@ let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
" }}} " }}}
" ------------------------------------------------------------------------- call vimwiki#u#reload_regexes()
" Load concrete Wiki syntax: sets regexes and templates for headers and links
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" -------------------------------------------------------------------------
let time0 = vimwiki#u#time(starttime) "XXX let time0 = vimwiki#u#time(starttime) "XXX
" LINKS: setup of larger regexes {{{ " LINKS: setup of larger regexes {{{
@ -399,10 +398,7 @@ syntax match VimwikiTableRow /^\s*|.\+|\s*$/
syntax match VimwikiCellSeparator syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained \ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
" List items " Lists
let g:vimwiki_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.join(g:vimwiki_listsyms, '').']\)\]\s\)\?'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/' execute 'syntax match VimwikiList /'.g:vimwiki_rxListItemWithoutCB.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/' execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/' execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListItem.'/'
@ -577,10 +573,8 @@ hi def link VimwikiLinkCharT VimwikiLinkT
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
"}}} "}}}
" -------------------------------------------------------------------------
" Load syntax-specific functionality " 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" " FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
let b:current_syntax="vimwiki" let b:current_syntax="vimwiki"

View File

@ -80,8 +80,10 @@ let g:vimwiki_number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
"it is used for i_<C-L><C-J> among other things "it is used for i_<C-L><C-J> among other things
let g:vimwiki_list_markers = ['-', '•', '1.', '*', 'I)', 'a)'] let g:vimwiki_list_markers = ['-', '•', '1.', '*', 'I)', 'a)']
let g:vimwiki_rxListDefine = '::\(\s\|$\)' let g:vimwiki_rxListDefine = '::\(\s\|$\)'
call vimwiki#lst#setup_marker_infos() 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.*\|^$\)\)*' let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
" Preformatted text " Preformatted text

View File

@ -78,6 +78,9 @@ let g:vimwiki_number_types = ['1.']
let g:vimwiki_list_markers = ['-', '*', '+', '1.'] let g:vimwiki_list_markers = ['-', '*', '+', '1.']
let g:vimwiki_rxListDefine = '::\%(\s\|$\)' let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
call vimwiki#lst#setup_marker_infos() 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.*\|^$\)\)*' let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
" Preformatted text " Preformatted text

View File

@ -59,7 +59,10 @@ let g:vimwiki_number_types = []
let g:vimwiki_list_markers = ['*', '#'] let g:vimwiki_list_markers = ['*', '#']
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s' let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
call vimwiki#lst#setup_marker_infos() 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 " Preformatted text
let g:vimwiki_rxPreStart = '<pre>' let g:vimwiki_rxPreStart = '<pre>'