From e56c26c7ba892fc6ee073df0f2457d899d24d433 Mon Sep 17 00:00:00 2001 From: Greg Anders Date: Thu, 28 Mar 2019 14:49:42 -0700 Subject: [PATCH] Add an option to conceal preformatted text blocks This merges PR #641. --- autoload/vimwiki/base.vim | 3 ++- autoload/vimwiki/vars.vim | 1 + doc/vimwiki.txt | 20 ++++++++++++++++++++ syntax/vimwiki.vim | 6 ++++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index a76962a..cf12dc4 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1022,10 +1022,11 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort let group='texMathZoneGroup' endif + let concealpre = vimwiki#vars#get_global('conceal_pre') ? ' concealends' : '' execute 'syntax region textSnip'.ft. \ ' matchgroup='.a:textSnipHl. \ ' start="'.a:start.'" end="'.a:end.'"'. - \ ' contains=@'.group.' keepend' + \ ' contains=@'.group.' keepend'.concealpre " A workaround to Issue 115: Nested Perl syntax highlighting differs from " regular one. diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 02c09c9..250bfc1 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -145,6 +145,7 @@ function! s:read_global_settings_from_user() \ 'auto_chdir': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'autowriteall': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'conceallevel': {'type': type(0), 'default': 2, 'min': 0, 'max': 3}, + \ 'conceal_pre': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'create_link': {'type': type(0), 'default': 1, 'min':0, 'max': 1}, \ 'diary_months': {'type': type({}), 'default': \ { diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index e02d4a7..da6e700 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -2887,6 +2887,26 @@ URLs and hides markers and URL for links that have a description. Default: 2 +------------------------------------------------------------------------------ +*g:vimwiki_conceal_pre* + +Conceal preformatted text markers. For example, +> + {{{python + def say_hello(): + print("Hello, world!") + }}} +> +would appear as simply +> + def say_hello(): + print("Hello, world!") +> +in your wiki file. + +Default: 0 + + ------------------------------------------------------------------------------ *g:vimwiki_autowriteall* diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim index fb311b4..30b0e5b 100644 --- a/syntax/vimwiki.vim +++ b/syntax/vimwiki.vim @@ -318,8 +318,9 @@ execute 'syntax match VimwikiCodeT /'.vimwiki#vars#get_syntaxlocal('rxCode'). "
horizontal rule execute 'syntax match VimwikiHR /'.vimwiki#vars#get_syntaxlocal('rxHR').'/' -execute 'syntax region VimwikiPre start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart'). - \ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@Spell' +let concealpre = vimwiki#vars#get_global('conceal_pre') ? ' concealends' : '' +execute 'syntax region VimwikiPre matchgroup=VimwikiPreDelim start=/'.vimwiki#vars#get_syntaxlocal('rxPreStart'). + \ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'/ contains=@Spell'.concealpre execute 'syntax region VimwikiMath start=/'.vimwiki#vars#get_syntaxlocal('rxMathStart'). \ '/ end=/'.vimwiki#vars#get_syntaxlocal('rxMathEnd').'/ contains=@Spell' @@ -395,6 +396,7 @@ hi def link VimwikiCodeT VimwikiCode hi def link VimwikiPre PreProc hi def link VimwikiPreT VimwikiPre +hi def link VimwikiPreDelim VimwikiPre hi def link VimwikiMath Number hi def link VimwikiMathT VimwikiMath