Skip to content

Commit

Permalink
Prevent embedded language syntaxes from changing 'foldmethod' (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konfekt authored Jan 31, 2020
1 parent f7ea41a commit 0d1129e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions syntax/pandoc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ endif
" Functions: {{{1
" EnableEmbedsforCodeblocksWithLang {{{2
function! EnableEmbedsforCodeblocksWithLang(entry)
" prevent embedded language syntaxes from changing 'foldmethod'
if has('folding')
let s:foldmethod = &l:foldmethod
endif

try
let s:langname = matchstr(a:entry, '^[^=]*')
let s:langsyntaxfile = matchstr(a:entry, '[^=]*$')
Expand All @@ -174,6 +179,10 @@ function! EnableEmbedsforCodeblocksWithLang(entry)
catch /E484/
echo "No syntax file found for '" . s:langsyntaxfile . "'"
endtry

if exists('s:foldmethod') && s:foldmethod !=# &l:foldmethod
let &l:foldmethod = s:foldmethod
endif
endfunction
" }}}2

Expand Down Expand Up @@ -225,6 +234,11 @@ endif

" Embeds: {{{2

" prevent embedded language syntaxes from changing 'foldmethod'
if has('folding')
let s:foldmethod = &l:foldmethod
endif

" HTML: {{{3
" Set embedded HTML highlighting
syn include @HTML syntax/html.vim
Expand Down Expand Up @@ -255,6 +269,10 @@ syn match pandocLaTexSectionCmd /\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)
syn match pandocLaTeXDelimiter /[[\]{}]/ contained containedin=pandocLaTexSection
" }}}3

if exists('s:foldmethod') && s:foldmethod !=# &l:foldmethod
let &l:foldmethod = s:foldmethod
endif

" }}}2

" Titleblock: {{{2
Expand Down

0 comments on commit 0d1129e

Please sign in to comment.