Skip to content

Commit 0d1129e

Browse files
authored
Prevent embedded language syntaxes from changing 'foldmethod' (#314)
As in tpope/vim-markdown@719b046
1 parent f7ea41a commit 0d1129e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

syntax/pandoc.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ endif
159159
" Functions: {{{1
160160
" EnableEmbedsforCodeblocksWithLang {{{2
161161
function! EnableEmbedsforCodeblocksWithLang(entry)
162+
" prevent embedded language syntaxes from changing 'foldmethod'
163+
if has('folding')
164+
let s:foldmethod = &l:foldmethod
165+
endif
166+
162167
try
163168
let s:langname = matchstr(a:entry, '^[^=]*')
164169
let s:langsyntaxfile = matchstr(a:entry, '[^=]*$')
@@ -174,6 +179,10 @@ function! EnableEmbedsforCodeblocksWithLang(entry)
174179
catch /E484/
175180
echo "No syntax file found for '" . s:langsyntaxfile . "'"
176181
endtry
182+
183+
if exists('s:foldmethod') && s:foldmethod !=# &l:foldmethod
184+
let &l:foldmethod = s:foldmethod
185+
endif
177186
endfunction
178187
" }}}2
179188

@@ -225,6 +234,11 @@ endif
225234

226235
" Embeds: {{{2
227236

237+
" prevent embedded language syntaxes from changing 'foldmethod'
238+
if has('folding')
239+
let s:foldmethod = &l:foldmethod
240+
endif
241+
228242
" HTML: {{{3
229243
" Set embedded HTML highlighting
230244
syn include @HTML syntax/html.vim
@@ -255,6 +269,10 @@ syn match pandocLaTexSectionCmd /\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)
255269
syn match pandocLaTeXDelimiter /[[\]{}]/ contained containedin=pandocLaTexSection
256270
" }}}3
257271

272+
if exists('s:foldmethod') && s:foldmethod !=# &l:foldmethod
273+
let &l:foldmethod = s:foldmethod
274+
endif
275+
258276
" }}}2
259277

260278
" Titleblock: {{{2

0 commit comments

Comments
 (0)