Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent that embedded language syntaxes change 'foldmethod' #314

Merged
merged 1 commit into from
Jan 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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