From a2888692fd05f9c60c4f0a2e5798d75add641690 Mon Sep 17 00:00:00 2001 From: mMontu Date: Wed, 27 Jan 2016 13:30:30 -0200 Subject: [PATCH] Option for automatic detection of nested syntaxes --- doc/vimwiki.txt | 14 ++++++++++++++ plugin/vimwiki.vim | 1 + syntax/vimwiki.vim | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index c145211..ae11ca2 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1940,6 +1940,20 @@ or in: > }}} +*vimwiki-option-automatic_nested_syntaxes* +------------------------------------------------------------------------------ +Key Default value~ +automatic_nested_syntaxes 1 + +Description~ +Allows for smaller |vimwiki-option-nested_syntaxes| dictionaries, by turning +entry for python on the previous example unnecessary: > + let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} + +It requires that the file is reloaded (|:edit|) after new |filetype| is +included in a file. + + *vimwiki-option-diary_rel_path* ------------------------------------------------------------------------------ Key Default value~ diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 8d3a577..a9fc7e2 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -390,6 +390,7 @@ let s:vimwiki_defaults.template_default = '' let s:vimwiki_defaults.template_ext = '' let s:vimwiki_defaults.nested_syntaxes = {} +let s:vimwiki_defaults.automatic_nested_syntaxes = 1 let s:vimwiki_defaults.auto_export = 0 let s:vimwiki_defaults.auto_toc = 0 " is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim index 4cf9d91..8925b95 100644 --- a/syntax/vimwiki.vim +++ b/syntax/vimwiki.vim @@ -600,7 +600,10 @@ call vimwiki#u#reload_regexes_custom() let b:current_syntax="vimwiki" " EMBEDDED syntax setup "{{{ -let s:nested = extend(VimwikiGet('nested_syntaxes'), vimwiki#base#detect_nested_syntax()) +let s:nested = VimwikiGet('nested_syntaxes') +if VimwikiGet('automatic_nested_syntaxes') + let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax()) +endif if !empty(s:nested) for [s:hl_syntax, s:vim_syntax] in items(s:nested) call vimwiki#base#nested_syntax(s:vim_syntax,