From: Hiroshi Shirosaki Date: Wed, 1 Feb 2017 06:39:43 +0000 (+0900) Subject: Merge pull request #303 from luzhlon/master X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/20aef6091bc1b6d75859b8a629162bac2a819b2f?hp=bf9cf6524bf5534430ca7145eeada968c9e96e03 Merge pull request #303 from luzhlon/master fixed the autofit bug --- diff --git a/.travis.yml b/.travis.yml index a913cd7..ab79fcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: | export PATH="/usr/local/bin:$PATH" cd "$TRAVIS_BUILD_DIR" fi - sudo pip install virtualenv + sudo -H pip install virtualenv stty cols 80 script: diff --git a/README.md b/README.md index 9c6665e..17c97b9 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,12 @@ let g:vim_markdown_folding_style_pythonic = 1 Level 1 heading which is served as a document title is not folded. `g:vim_markdown_folding_level` setting is not active with this fold style. +To prevent foldtext from being set add the following to your `.vimrc`: + +```vim +let g:vim_markdown_override_foldtext = 0 +``` + ### Set header folding level Folding level is a number between 1 and 6. By default, if not specified, it is set to 1. @@ -128,6 +134,9 @@ let g:vim_markdown_emphasis_multiline = 0 Concealing is set for some syntax. For example, conceal `[link text](link url)` as just `link text`. +Also, `_italic_` and `*italic*` will conceal to just _italic_. +Similarly `__bold__`, `**bold**`, `___italic bold___`, and `***italic bold***` +will conceal to just __bold__, **bold**, ___italic bold___, and ***italic bold*** respectively. To enable conceal use Vim's standard conceal configuration. diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim index 6265db3..cdf0a26 100644 --- a/after/ftplugin/markdown.vim +++ b/after/ftplugin/markdown.vim @@ -150,7 +150,7 @@ let s:vim_markdown_folding_level = get(g:, "vim_markdown_folding_level", 1) if !get(g:, "vim_markdown_folding_disabled", 0) setlocal foldexpr=Foldexpr_markdown(v:lnum) setlocal foldmethod=expr - if get(g:, "vim_markdown_folding_style_pythonic", 0) + if get(g:, "vim_markdown_folding_style_pythonic", 0) && get(g:, "vim_markdown_override_foldtext", 1) setlocal foldtext=Foldtext_markdown() endif endif diff --git a/doc/vim-markdown.txt b/doc/vim-markdown.txt index eb61653..3ee30e6 100644 --- a/doc/vim-markdown.txt +++ b/doc/vim-markdown.txt @@ -96,6 +96,10 @@ To fold in a style like python-mode [6], add the following to your '.vimrc': Level 1 heading which is served as a document title is not folded. 'g:vim_markdown_folding_level' setting is not active with this fold style. +To prevent foldtext from being overridden, add the following to your '.vimrc': + + let g:vim_markdown_override_foldtext = 0 + ------------------------------------------------------------------------------- *vim-markdown-set-header-folding-level* Set header folding level ~ @@ -146,6 +150,9 @@ Syntax Concealing ~ Concealing is set for some syntax. For example, conceal '[link text](link url)' as just 'link text'. +Also, '_italic_' and '*italic*' will conceal to just 'italic'. +Similarly '__bold__', '**bold**', '___italic bold___', and '***italic bold***' +will conceal to 'bold', 'bold', 'italic bold', and 'italic bold' respectively. To enable conceal use Vim's standard conceal configuration. > diff --git a/syntax/markdown.vim b/syntax/markdown.vim index 72ba6a5..5df0430 100644 --- a/syntax/markdown.vim +++ b/syntax/markdown.vim @@ -47,12 +47,15 @@ if get(g:, 'vim_markdown_emphasis_multiline', 1) else let s:oneline = ' oneline' endif -execute 'syn region htmlItalic start="\%(^\|\s\)\zs\*\ze[^\\\*\t ]\%(\%([^*]\|\\\*\|\n\)*[^\\\*\t ]\)\?\*\_W" end="[^\\\*\t ]\zs\*\ze\_W" keepend' . s:oneline -execute 'syn region htmlItalic start="\%(^\|\s\)\zs_\ze[^\\_\t ]" end="[^\\_\t ]\zs_\ze\_W" keepend' . s:oneline -execute 'syn region htmlBold start="\%(^\|\s\)\*\*\ze\S" end="\S\zs\*\*" keepend' . s:oneline -execute 'syn region htmlBold start="\%(^\|\s\)\zs__\ze\S" end="\S\zs__" keepend' . s:oneline -execute 'syn region htmlBoldItalic start="\%(^\|\s\)\zs\*\*\*\ze\S" end="\S\zs\*\*\*" keepend' . s:oneline -execute 'syn region htmlBoldItalic start="\%(^\|\s\)\zs___\ze\S" end="\S\zs___" keepend' . s:oneline +syn region mkdItalic matchgroup=mkdItalic start="\%(\*\|_\)" end="\%(\*\|_\)" +syn region mkdBold matchgroup=mkdBold start="\%(\*\*\|__\)" end="\%(\*\*\|__\)" +syn region mkdBoldItalic matchgroup=mkdBoldItalic start="\%(\*\*\*\|___\)" end="\%(\*\*\*\|___\)" +execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs\*\ze[^\\\*\t ]\%(\%([^*]\|\\\*\|\n\)*[^\\\*\t ]\)\?\*\_W" end="[^\\\*\t ]\zs\*\ze\_W" keepend' . s:oneline . s:concealends +execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs_\ze[^\\_\t ]" end="[^\\_\t ]\zs_\ze\_W" keepend' . s:oneline . s:concealends +execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs\*\*\ze\S" end="\S\zs\*\*" keepend' . s:oneline . s:concealends +execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs__\ze\S" end="\S\zs__" keepend' . s:oneline . s:concealends +execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs\*\*\*\ze\S" end="\S\zs\*\*\*" keepend' . s:oneline . s:concealends +execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs___\ze\S" end="\S\zs___" keepend' . s:oneline . s:concealends " [link](URL) | [link][id] | [link][] | ![image](URL) syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]" @@ -102,7 +105,7 @@ syn region mkdFootnote start="\[^" end="\]" syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained -syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\s\+/ contained +syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\ze\s\+/ contained syn region mkdListItemLine start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" oneline contains=@mkdNonListItem,mkdListItem,@Spell syn region mkdNonListItemBlock start="\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!\)" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/ diff --git a/test/syntax.vader b/test/syntax.vader index 2f5f78c..b08a9a0 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -167,6 +167,234 @@ Execute (not bold with double underscores): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertNotEqual SyntaxOf('b'), 'htmlBold' +Given markdown; +_a_ + +Execute (conceal italic): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +*a* + +Execute (conceal italic): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +__a__ + +Execute (conceal bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +**a** + +Execute (conceal bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +___a___ + +Execute (conceal italic bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + AssertEqual synconcealed(1, 6)[0], 0 + AssertEqual synconcealed(1, 7)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +***a*** + +Execute (conceal italic bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + AssertEqual synconcealed(1, 6)[0], 0 + AssertEqual synconcealed(1, 7)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + # Links Given markdown;