Dynamically detect nested syntaxes (fix #128)

This commit is contained in:
mMontu 2016-01-27 10:14:49 -02:00
parent edb72680a1
commit fc947523b0
2 changed files with 13 additions and 1 deletions

View File

@ -1926,6 +1926,18 @@ function! vimwiki#base#normalize_link(is_visual_mode) "{{{
endif endif
endfunction "}}} endfunction "}}}
" vimwiki#base#detect_nested_syntax
function! vimwiki#base#detect_nested_syntax() "{{{
let last_word = '\v.*<(\w+)\s*$'
let lines = map(filter(getline(1, "$"), 'v:val =~ "{{{" && v:val =~ last_word'),
\ 'substitute(v:val, last_word, "\\=submatch(1)", "")')
let dict = {}
for elem in lines
exe "let dict.".elem." = elem"
endfor
return dict
endfunction "}}}
" }}} " }}}
" Command completion functions {{{ " Command completion functions {{{

View File

@ -600,7 +600,7 @@ call vimwiki#u#reload_regexes_custom()
let b:current_syntax="vimwiki" let b:current_syntax="vimwiki"
" EMBEDDED syntax setup "{{{ " EMBEDDED syntax setup "{{{
let s:nested = VimwikiGet('nested_syntaxes') let s:nested = extend(VimwikiGet('nested_syntaxes'), vimwiki#base#detect_nested_syntax())
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,