Simplify some regexes
This commit is contained in:
parent
128581babc
commit
4bd0690a52
@ -376,10 +376,10 @@ endfunction "}}}
|
|||||||
"If there is no second argument, 0 is returned at a header, otherwise the
|
"If there is no second argument, 0 is returned at a header, otherwise the
|
||||||
"header is skipped
|
"header is skipped
|
||||||
function! s:get_next_line(lnum, ...) "{{{
|
function! s:get_next_line(lnum, ...) "{{{
|
||||||
if getline(a:lnum) =~# '^\s*'.g:vimwiki_rxPreStart
|
if getline(a:lnum) =~# g:vimwiki_rxPreStart
|
||||||
let cur_ln = a:lnum + 1
|
let cur_ln = a:lnum + 1
|
||||||
while cur_ln <= line('$') &&
|
while cur_ln <= line('$') &&
|
||||||
\ getline(cur_ln) !~# '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
\ getline(cur_ln) !~# g:vimwiki_rxPreEnd
|
||||||
let cur_ln += 1
|
let cur_ln += 1
|
||||||
endwhile
|
endwhile
|
||||||
let next_line = cur_ln
|
let next_line = cur_ln
|
||||||
@ -404,10 +404,10 @@ endfunction "}}}
|
|||||||
function! s:get_prev_line(lnum) "{{{
|
function! s:get_prev_line(lnum) "{{{
|
||||||
let prev_line = prevnonblank(a:lnum-1)
|
let prev_line = prevnonblank(a:lnum-1)
|
||||||
|
|
||||||
if getline(prev_line) =~# '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
if getline(prev_line) =~# g:vimwiki_rxPreEnd
|
||||||
let cur_ln = a:lnum - 1
|
let cur_ln = a:lnum - 1
|
||||||
while 1
|
while 1
|
||||||
if cur_ln == 0 || getline(cur_ln) =~# '^\s*'.g:vimwiki_rxPreStart
|
if cur_ln == 0 || getline(cur_ln) =~# g:vimwiki_rxPreStart
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
let cur_ln -= 1
|
let cur_ln -= 1
|
||||||
|
@ -173,9 +173,9 @@ function! VimwikiFoldLevel(lnum) "{{{
|
|||||||
if line =~# g:vimwiki_rxHeader
|
if line =~# g:vimwiki_rxHeader
|
||||||
return '>'.vimwiki#u#count_first_sym(line)
|
return '>'.vimwiki#u#count_first_sym(line)
|
||||||
" Code block folding...
|
" Code block folding...
|
||||||
elseif line =~# '^\s*'.g:vimwiki_rxPreStart
|
elseif line =~# g:vimwiki_rxPreStart
|
||||||
return 'a1'
|
return 'a1'
|
||||||
elseif line =~# '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
elseif line =~# g:vimwiki_rxPreEnd
|
||||||
return 's1'
|
return 's1'
|
||||||
else
|
else
|
||||||
return "="
|
return "="
|
||||||
@ -221,7 +221,7 @@ function! VimwikiFoldText() "{{{
|
|||||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||||
let fold_len = v:foldend - v:foldstart + 1
|
let fold_len = v:foldend - v:foldstart + 1
|
||||||
let len_text = ' ['.fold_len.'] '
|
let len_text = ' ['.fold_len.'] '
|
||||||
if line !~# '^\s*'.g:vimwiki_rxPreStart
|
if line !~# g:vimwiki_rxPreStart
|
||||||
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
let [main_text, spare_len] = s:shorten_text(main_text, 50)
|
||||||
return main_text.len_text
|
return main_text.len_text
|
||||||
else
|
else
|
||||||
|
@ -315,6 +315,12 @@ endfor
|
|||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
let g:vimwiki_rxPreStart = '^\s*'.g:vimwiki_rxPreStart
|
||||||
|
let g:vimwiki_rxPreEnd = '^\s*'.g:vimwiki_rxPreEnd.'\s*$'
|
||||||
|
|
||||||
|
let g:vimwiki_rxMathStart = '^\s*'.g:vimwiki_rxMathStart
|
||||||
|
let g:vimwiki_rxMathEnd = '^\s*'.g:vimwiki_rxMathEnd.'\s*$'
|
||||||
|
|
||||||
" possibly concealed chars " {{{
|
" possibly concealed chars " {{{
|
||||||
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
|
let s:conceal = exists("+conceallevel") ? ' conceal' : ''
|
||||||
|
|
||||||
@ -444,11 +450,11 @@ execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=Vim
|
|||||||
" <hr> horizontal rule
|
" <hr> horizontal rule
|
||||||
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
|
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
|
||||||
|
|
||||||
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
|
execute 'syntax region VimwikiPre start=/'.g:vimwiki_rxPreStart.
|
||||||
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
|
\ '/ end=/'.g:vimwiki_rxPreEnd.'/ contains=@Spell'
|
||||||
|
|
||||||
execute 'syntax region VimwikiMath start=/^\s*'.g:vimwiki_rxMathStart.
|
execute 'syntax region VimwikiMath start=/'.g:vimwiki_rxMathStart.
|
||||||
\ '/ end=/^\s*'.g:vimwiki_rxMathEnd.'\s*$/ contains=@Spell'
|
\ '/ end=/'.g:vimwiki_rxMathEnd.'/ contains=@Spell'
|
||||||
|
|
||||||
|
|
||||||
" placeholders
|
" placeholders
|
||||||
@ -594,16 +600,16 @@ endif
|
|||||||
if !empty(s:nested)
|
if !empty(s:nested)
|
||||||
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
|
for [s:hl_syntax, s:vim_syntax] in items(s:nested)
|
||||||
call vimwiki#base#nested_syntax(s:vim_syntax,
|
call vimwiki#base#nested_syntax(s:vim_syntax,
|
||||||
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
\ g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||||
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
\ s:hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||||
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
|
\ g:vimwiki_rxPreEnd, 'VimwikiPre')
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
" LaTeX
|
" LaTeX
|
||||||
call vimwiki#base#nested_syntax('tex',
|
call vimwiki#base#nested_syntax('tex',
|
||||||
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
\ g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||||
\ '\%([[:blank:][:punct:]].*\)\?',
|
\ '\%([[:blank:][:punct:]].*\)\?',
|
||||||
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
|
\ g:vimwiki_rxMathEnd, 'VimwikiMath')
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user