Closed cdoepmann closed 4 years ago
it's true, this is a problem, it is probably caused by the list item matching patterns, i am not sure. but i suggest you use tabs instead of spaces for indents, that may be a good practice and workaround though.
i've figured out what's the problem, with :syntime on
and :syntime report
TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
22.513534 14100 0 1.703281 0.001597 markdownCodeBlock \%(^\n\)\@<=\%(\%(\s\{4,}\|\t\+\).*\n\)\+$
this regex takes too long to finish, to fix it, replace
syn match markdownCodeBlock /\%(^\n\)\@<=\%(\%(\s\{4,}\|\t\+\).*\n\)\+$/ contains=@NoSpell
in syntax/markdown.vim with
syn match markdownCodeBlock /\%(^\n\)\@<=\%(\%( \{4}\|\t\+\).*\n\)\+$/ contains=@NoSpell
it will fix the problem,
but it still takes several milliseconds, to me, i personal don't use spaces for indention, the following will be much faster
syn match markdownCodeBlock /\%(^\n\)\@<=\%(\%(\t\+\).*\n\)\+$/ contains=@NoSpell
and, this markdown syntax highlight has a lot of regexes that may consume a lot, i simplify some mathing rules to save rendering time, if any one encounters the performance issue of syntax highlight, give it a try to simplify the matching rules.
This solution is working very well for me. Is there is chance it will get integrated?
hi! Wiliarty, i opened a pull request 5 months ago for this change, but it seems no one accepts the PR
here is my repo for vim, it contains all the changes which may affect performance
<github.com/gavinchou/vim_config>
check it (.vim/syntax/markdown.vim) out if you are interested in vim and dont forget to star it if it helps, LOL
Looks nice. Thanks very much for the tip.
@gavinchou Maybe you could create fork that fixes performance issues and add syntax highlight for code blocks?
Fixed by #78
Hi, I am experiencing vim-markdown to be extremely slow when processing a file like this:
The performance further degrades when more
foo
lines are added.I am aware of the fact that this probably isn't valid or well-formed Markdown. However, I noticed it by accidentally indenting a bunch of lines, which resulted in vim effectively freezing. I do not think that this should happen even for arbitrary input.
I'm using: