Skip to content

Commit 68d7249

Browse files
jezfmoralesc
authored andcommitted
Optionally disable definition lists (#212)
* Optionally disable definition lists In documents which make heavy use of definition lists, vim-pandoc can causes Vim to re-render really slowly. Make syntax highlighting of definition lists optional.
1 parent 8934152 commit 68d7249

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

doc/pandoc-syntax.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ CONFIGURATION *vim-pandoc-syntax-configuration*
7777
+ *g:pandoc#syntax#style#underline_special*
7878
Undeline subscript, superscript and strikeout text styles. Default = 1
7979

80+
+ *g:pandoc#syntax#style#use_definition_lists*
81+
Detect and highlight definition lists. Disabling this can improve
82+
performance. Default = 1 (i.e., enabled by default)
83+
8084
COMMANDS *pandoc-syntax-commands*
8185

8286
+ *:PandocHighlight* LANG

syntax/pandoc.vim

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ if !exists('g:pandoc#syntax#roman_lists')
132132
let g:pandoc#syntax#roman_lists = 0
133133
endif
134134
" }}}
135+
" disable syntax highlighting for definition lists? (better performances) {{{2
136+
if !exists('g:pandoc#syntax#use_definition_lists')
137+
let g:pandoc#syntax#use_definition_lists = 1
138+
endif
139+
" }}}
135140
"}}}1
136141

137142
" Functions: {{{1
@@ -435,9 +440,11 @@ syn match pandocListItemContinuation /^\s\+\([-+*]\s\+\|(\?.\+[).]\)\@<!\([[:alp
435440
" }}}
436441
" Definitions: {{{2
437442
"
438-
syn region pandocDefinitionBlock start=/^\%(\_^\s*\([`~]\)\1\{2,}\)\@!.*\n\(^\s*\n\)\=\s\{0,2}[:~]\(\~\{2,}\~*\)\@!/ skip=/\n\n\zs\s/ end=/\n\n/ contains=pandocDefinitionBlockMark,pandocDefinitionBlockTerm,pandocCodeBlockInsideIndent,pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocFootnoteID,pandocReferenceURL,pandocReferenceLabel,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink,pandocEmDash,pandocEnDash,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID
439-
syn match pandocDefinitionBlockTerm /^.*\n\(^\s*\n\)\=\(\s*[:~]\)\@=/ contained contains=pandocNoFormatted,pandocEmphasis,pandocStrong,pandocLaTeXInlineMath,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID nextgroup=pandocDefinitionBlockMark
440-
call s:WithConceal("definition", 'syn match pandocDefinitionBlockMark /^\s*[:~]/ contained', 'conceal cchar='.s:cchars["definition"])
443+
if g:pandoc#syntax#use_definition_lists == 1
444+
syn region pandocDefinitionBlock start=/^\%(\_^\s*\([`~]\)\1\{2,}\)\@!.*\n\(^\s*\n\)\=\s\{0,2}[:~]\(\~\{2,}\~*\)\@!/ skip=/\n\n\zs\s/ end=/\n\n/ contains=pandocDefinitionBlockMark,pandocDefinitionBlockTerm,pandocCodeBlockInsideIndent,pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocFootnoteID,pandocReferenceURL,pandocReferenceLabel,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink,pandocEmDash,pandocEnDash,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID
445+
syn match pandocDefinitionBlockTerm /^.*\n\(^\s*\n\)\=\(\s*[:~]\)\@=/ contained contains=pandocNoFormatted,pandocEmphasis,pandocStrong,pandocLaTeXInlineMath,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID nextgroup=pandocDefinitionBlockMark
446+
call s:WithConceal("definition", 'syn match pandocDefinitionBlockMark /^\s*[:~]/ contained', 'conceal cchar='.s:cchars["definition"])
447+
endif
441448
" }}}
442449
" Special: {{{2
443450

0 commit comments

Comments
 (0)