From: Hiroshi Shirosaki Date: Tue, 26 Mar 2019 00:36:59 +0000 (+0900) Subject: Merge pull request #423 from tobinjt/folding-fix X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/a15334cac67237835e62c9dd1470f6162769779f?hp=bd8236d1651267d2b4b805a1e87afd66f53a2bdb Merge pull request #423 from tobinjt/folding-fix Folding fix --- diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim index 9ee0100..41dfd94 100644 --- a/after/ftplugin/markdown.vim +++ b/after/ftplugin/markdown.vim @@ -151,10 +151,20 @@ let b:fenced_block = 0 let b:front_matter = 0 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) && get(g:, "vim_markdown_override_foldtext", 1) - setlocal foldtext=Foldtext_markdown() - endif -endif +function! s:MarkdownSetupFolding() + 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) && get(g:, "vim_markdown_override_foldtext", 1) + setlocal foldtext=Foldtext_markdown() + endif + endif +endfunction +call s:MarkdownSetupFolding() +augroup Mkd + " These autocmds need to be kept in sync with the autocmds calling + " s:MarkdownRefreshSyntax in ftplugin/markdown.vim. + autocmd BufWinEnter,BufWritePost call s:MarkdownSetupFolding() + autocmd InsertEnter,InsertLeave call s:MarkdownSetupFolding() + autocmd CursorHold,CursorHoldI call s:MarkdownSetupFolding() +augroup END diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index 989aef8..200293e 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -780,6 +780,8 @@ function! s:MarkdownClearSyntaxVariables() endfunction augroup Mkd + " These autocmd calling s:MarkdownRefreshSyntax need to be kept in sync with + " the autocmds calling s:MarkdownSetupFolding in after/ftplugin/markdown.vim. autocmd! * autocmd BufWinEnter call s:MarkdownRefreshSyntax(1) autocmd BufUnload call s:MarkdownClearSyntaxVariables()