Issue 2: g:vimwiki_rxListBullet is not defined

Move g:vimwiki_rxListBullet definition to corresponding syntax files.

Restore multiple bullets (*, **, ***) functionality, set up vimwiki
default lists have only one bullet.
This commit is contained in:
Maxim Kim 2013-07-14 20:58:46 +04:00
parent a405c7317a
commit 6d15d32652
6 changed files with 45 additions and 40 deletions

View File

@ -992,6 +992,14 @@ function! s:adjust_mrkr(item) "{{{
let new_mrkr = neighbor_item.mrkr let new_mrkr = neighbor_item.mrkr
endif endif
"if possible, set e.g. *** if parent has ** as marker
if neighbor_item.type == 0 && a:item.type == 1 && has_key(g:vimwiki_bullet_points, s:first_char(a:item.mrkr)) && g:vimwiki_bullet_points[s:first_char(a:item.mrkr)] == 1
let parent_item = s:get_parent(a:item)
if parent_item.type == 1 && s:first_char(parent_item.mrkr) == s:first_char(a:item.mrkr)
let new_mrkr = repeat(s:first_char(parent_item.mrkr), s:string_length(parent_item.mrkr)+1)
endif
endif
call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, new_mrkr) call s:substitute_string_in_line(a:item.lnum, a:item.mrkr, new_mrkr)
call s:adjust_numbered_list(a:item, 0, 1) call s:adjust_numbered_list(a:item, 0, 1)
endfunction "}}} endfunction "}}}

View File

@ -44,47 +44,11 @@ setlocal formatoptions-=2
setlocal formatoptions+=n setlocal formatoptions+=n
if VimwikiGet('syntax') == 'default'
"1 means multiple bullets, like * ** ***
let g:vimwiki_bullet_points = { '-':0, '*':1, '#':1 , '◆':1}
let g:vimwiki_bullet_numbers = ['1iIaA', '.)]']
"this should contain at least one element
"it is used for i_<C-A> among other things
let g:vimwiki_list_markers = ['-', '#', '◆', '1.', 'i)', 'a)']
elseif VimwikiGet('syntax') == 'markdown'
let g:vimwiki_bullet_points = { '-':0, '*':0, '+':0 }
let g:vimwiki_bullet_numbers = ['1', '.']
let g:vimwiki_list_markers = ['-', '*', '+', '1.']
else "media
"better leave this as it is, because media syntax is special
let g:vimwiki_bullet_points = { '*':1, '#':1 }
let g:vimwiki_bullet_numbers = ['', '']
let g:vimwiki_list_markers = ['*', '#']
endif
let g:vimwiki_rxListBullet = join( map(keys(g:vimwiki_bullet_points), 'vimwiki#u#escape(v:val) . repeat("\\+", g:vimwiki_bullet_points[v:val])') , '\|')
"create regex for numbered list
if g:vimwiki_bullet_numbers[0] == ''
"regex that matches nothing
let g:vimwiki_rxListNumber = '$^'
else
let s:char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+', 'a': '\l\{1,3}', 'A': '\u\{1,3}'}
let g:vimwiki_rxListNumber = '\C\%(' . join( map(split(g:vimwiki_bullet_numbers[0], '.\zs'), "s:char_to_rx[v:val]"), '\|').'\)'
let g:vimwiki_rxListNumber .= '['.vimwiki#u#escape(g:vimwiki_bullet_numbers[1]).']'
endif
if VimwikiGet('syntax') == 'default' || VimwikiGet('syntax') == 'markdown'
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
else
let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|^\s.*\)\)*'
endif
"Create 'formatlistpat' "Create 'formatlistpat'
let &formatlistpat = vimwiki#lst#get_list_item_rx(1) let &formatlistpat = vimwiki#lst#get_list_item_rx(1)
if !empty(&langmap) if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars " Valid only if langmap is a comma separated pairs of chars
let l_o = matchstr(&langmap, '\C,\zs.\zeo,') let l_o = matchstr(&langmap, '\C,\zs.\zeo,')

View File

@ -49,7 +49,6 @@ 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 {{{
" LINKS: setup wikilink regexps {{{ " LINKS: setup wikilink regexps {{{
@ -275,7 +274,6 @@ call s:add_target_syntax_ON(target, 'VimwikiLink')
" }}} " }}}
" generic headers "{{{ " generic headers "{{{
if g:vimwiki_symH if g:vimwiki_symH
"" symmetric "" symmetric
@ -379,6 +377,28 @@ let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/' execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" }}} " }}}
" Lists "{{{
let g:vimwiki_rxListBullet = join( map(keys(g:vimwiki_bullet_points), 'vimwiki#u#escape(v:val) . repeat("\\+", g:vimwiki_bullet_points[v:val])') , '\|')
"create regex for numbered list
if g:vimwiki_bullet_numbers[0] == ''
"regex that matches nothing
let g:vimwiki_rxListNumber = '$^'
else
let s:char_to_rx = {'1': '\d\+', 'i': '[ivxlcdm]\+', 'I': '[IVXLCDM]\+', 'a': '\l\{1,3}', 'A': '\u\{1,3}'}
let g:vimwiki_rxListNumber = '\C\%(' . join( map(split(g:vimwiki_bullet_numbers[0], '.\zs'), "s:char_to_rx[v:val]"), '\|').'\)'
let g:vimwiki_rxListNumber .= '['.vimwiki#u#escape(g:vimwiki_bullet_numbers[1]).']'
endif
" XXX: Should this be in corresponding syntax file?
if VimwikiGet('syntax') == 'default' || VimwikiGet('syntax') == 'markdown'
let g:vimwiki_rxListItemAndChildren = '^\(\s*\)\%('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\s.*\|^$\)\)*'
else
let g:vimwiki_rxListItemAndChildren = '^\('.g:vimwiki_rxListBullet.'\)\s\+\['.g:vimwiki_listsyms[4].'\]\s.*\%(\n\%(\1\%('.g:vimwiki_rxListBullet.'\).*\|^$\|^\s.*\)\)*'
endif
"}}}
" main syntax groups {{{ " main syntax groups {{{
" Tables " Tables
@ -494,8 +514,6 @@ else
endif endif
"}}} "}}}
" syntax group highlighting "{{{ " syntax group highlighting "{{{
hi def link VimwikiMarkers Normal hi def link VimwikiMarkers Normal

View File

@ -72,6 +72,13 @@ let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|' " Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|' let g:vimwiki_rxTableSep = '|'
" Lists
"1 means multiple bullets, like * ** ***
let g:vimwiki_bullet_points = { '-':0, '*':0, '#':0 , '◆':0}
let g:vimwiki_bullet_numbers = ['1iIaA', '.)]']
"this should contain at least one element
"it is used for i_<C-A> among other things
let g:vimwiki_list_markers = ['-', '#', '◆', '1.', 'i)', 'a)']
let g:vimwiki_rxListDefine = '::\(\s\|$\)' let g:vimwiki_rxListDefine = '::\(\s\|$\)'
" Preformatted text " Preformatted text

View File

@ -72,6 +72,10 @@ let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|' " Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|' let g:vimwiki_rxTableSep = '|'
" Lists
let g:vimwiki_bullet_points = { '-':0, '*':0, '+':0 }
let g:vimwiki_bullet_numbers = ['1', '.']
let g:vimwiki_list_markers = ['-', '*', '+', '1.']
let g:vimwiki_rxListDefine = '::\%(\s\|$\)' let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
" Preformatted text " Preformatted text

View File

@ -53,6 +53,10 @@ let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|' " Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|' let g:vimwiki_rxTableSep = '|'
" Lists
let g:vimwiki_bullet_points = { '*':1, '#':1 }
let g:vimwiki_bullet_numbers = ['', '']
let g:vimwiki_list_markers = ['*', '#']
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s' let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
" Preformatted text " Preformatted text