Start refactoring the rest -- part 3

Ref #256
This commit is contained in:
EinfachToll 2016-12-31 20:47:19 +01:00
parent 7c98ce3934
commit b82245b09e
3 changed files with 37 additions and 35 deletions

View File

@ -310,50 +310,59 @@ function! vimwiki#vars#populate_syntax_vars(syntax)
endif endif
let g:vimwiki_syntax_variables[a:syntax].rxPreStart = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreStart let g:vimwiki_syntax_variables[a:syntax].rxPreStart = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreStart
let g:vimwiki_rxPreEnd = '^\s*'.g:vimwiki_rxPreEnd.'\s*$' let g:vimwiki_syntax_variables[a:syntax].rxPreEnd = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxPreEnd.'\s*$'
let g:vimwiki_rxMathStart = '^\s*'.g:vimwiki_rxMathStart let g:vimwiki_syntax_variables[a:syntax].rxMathStart = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathStart
let g:vimwiki_rxMathEnd = '^\s*'.g:vimwiki_rxMathEnd.'\s*$' let g:vimwiki_syntax_variables[a:syntax].rxMathEnd = '^\s*'.g:vimwiki_syntax_variables[a:syntax].rxMathEnd.'\s*$'
" list stuff " list stuff
let rx_bullet_chars = '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+' let rx_bullet_chars = '['.join(g:vimwiki_syntax_variables[a:syntax].bullet_types, '').']\+'
let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars = g:vimwiki_syntax_variables[a:syntax].recurring_bullets ? g:vimwiki_syntax_variables[a:syntax].bullet_types : [] let g:vimwiki_syntax_variables[a:syntax].multiple_bullet_chars = g:vimwiki_syntax_variables[a:syntax].recurring_bullets ? g:vimwiki_syntax_variables[a:syntax].bullet_types : []
let s:number_kinds = [] let g:vimwiki_syntax_variables[a:syntax].number_kinds = []
let s:number_divisors = "" let g:vimwiki_syntax_variables[a:syntax].number_divisors = ''
for i in g:vimwiki_number_types for i in g:vimwiki_syntax_variables[a:syntax].number_types
call add(s:number_kinds, i[0]) call add(g:vimwiki_syntax_variables[a:syntax].number_kinds, i[0])
let s:number_divisors .= vimwiki#u#escape(i[1]) let g:vimwiki_syntax_variables[a:syntax].number_divisors .= vimwiki#u#escape(i[1])
endfor endfor
let s:char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+', let char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+',
\ 'a': '\l\{1,2}', 'A': '\u\{1,2}'} \ 'a': '\l\{1,2}', 'A': '\u\{1,2}'}
"create regexp for bulleted list items "create regexp for bulleted list items
let g:vimwiki_rxListBullet = join( map(keys(bullet_types), if !empty(g:vimwiki_syntax_variables[a:syntax].bullet_types)
\'vimwiki#u#escape(v:val).repeat("\\+", bullet_types[v:val])' let g:vimwiki_syntax_variables[a:syntax].rxListBullet = join( map(g:vimwiki_syntax_variables[a:syntax].bullet_types,
\'vimwiki#u#escape(v:val).repeat("\\+", g:vimwiki_syntax_variables[a:syntax].recurring_bullets)'
\ ) , '\|') \ ) , '\|')
"create regex for numbered list items
if !empty(g:vimwiki_number_types)
let g:vimwiki_rxListNumber = '\C\%('
for type in g:vimwiki_number_types[:-2]
let g:vimwiki_rxListNumber .= s:char_to_rx[type[0]] .
\ vimwiki#u#escape(type[1]) . '\|'
endfor
let g:vimwiki_rxListNumber .= s:char_to_rx[g:vimwiki_number_types[-1][0]].
\ vimwiki#u#escape(g:vimwiki_number_types[-1][1]) . '\)'
else else
"regex that matches nothing "regex that matches nothing
let g:vimwiki_rxListNumber = '$^' let g:vimwiki_syntax_variables[a:syntax].rxListBullet = '$^'
endif
"create regex for numbered list items
if !empty(g:vimwiki_syntax_variables[a:syntax].number_types)
let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '\C\%('
for type in g:vimwiki_syntax_variables[a:syntax].number_types[:-2]
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .= char_to_rx[type[0]] .
\ vimwiki#u#escape(type[1]) . '\|'
endfor
let g:vimwiki_syntax_variables[a:syntax].rxListNumber .= char_to_rx[g:vimwiki_syntax_variables[a:syntax].number_types[-1][0]].
\ vimwiki#u#escape(g:vimwiki_syntax_variables[a:syntax].number_types[-1][1]) . '\)'
else
"regex that matches nothing
let g:vimwiki_syntax_variables[a:syntax].rxListNumber = '$^'
endif endif
"the user can set the listsyms as string, but vimwiki needs a list "the user can set the listsyms as string, but vimwiki needs a list
let g:vimwiki_listsyms_list = split(vimwiki#vars#get_global('listsyms'), '\zs') let g:vimwiki_syntax_variables[a:syntax].listsyms_list = split(vimwiki#vars#get_global('listsyms'), '\zs')
let s:default_syntax.rxListItemWithoutCB = '^\s*\%(\('.s:default_syntax.rxListBullet.'\)\|\('.s:default_syntax.rxListNumber.'\)\)\s' let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\|\('.g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\)\s'
let s:default_syntax.rxListItem = s:default_syntax.rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?' let g:vimwiki_syntax_variables[a:syntax].rxListItem = g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
let s:default_syntax.rxListItemAndChildren = '^\(\s*\)\%('.s:default_syntax.rxListBullet.'\|'.s:default_syntax.rxListNumber.'\)\s\+\['.s:default_syntax.listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*' if g:vimwiki_syntax_variables[a:syntax].recurring_bullets
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = '^\('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\)\s\+\['.g:vimwiki_syntax_variables[a:syntax].listsyms_list[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\).*\|^$\|\s.*\)\)*'
else
let g:vimwiki_syntax_variables[a:syntax].rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_syntax_variables[a:syntax].rxListBullet.'\|'.g:vimwiki_syntax_variables[a:syntax].rxListNumber.'\)\s\+\['.g:vimwiki_syntax_variables[a:syntax].listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
endif
endfunction endfunction

View File

@ -69,16 +69,13 @@ let g:vimwiki_rxHR = '^-----*$'
let g:vimwiki_rxTableSep = '|' let g:vimwiki_rxTableSep = '|'
" Lists " Lists
let g:vimwiki_bullet_types = { '-':0, '*':0, '+':0 } let g:vimwiki_bullet_types = ['-', '*', '+']
let s:media_syntax.recurring_bullets = 0
let g:vimwiki_number_types = ['1.'] 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 . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
" Preformatted text " Preformatted text
let g:vimwiki_rxPreStart = '```' let g:vimwiki_rxPreStart = '```'
let g:vimwiki_rxPreEnd = '```' let g:vimwiki_rxPreEnd = '```'

View File

@ -57,10 +57,6 @@ 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_rxListItemWithoutCB = '^\s*\%(\('.g:vimwiki_rxListBullet.'\)\|\('.g:vimwiki_rxListNumber.'\)\)\s'
let g:vimwiki_rxListItem = g:vimwiki_rxListItemWithoutCB . '\+\%(\[\(['.vimwiki#vars#get_global('listsyms').']\)\]\s\)\?'
let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms_list[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|\s.*\)\)*'
" Preformatted text " Preformatted text
let g:vimwiki_rxPreStart = '<pre>' let g:vimwiki_rxPreStart = '<pre>'
let g:vimwiki_rxPreEnd = '<\/pre>' let g:vimwiki_rxPreEnd = '<\/pre>'