chrisbra/vim-zsh

Limit syncing (maxlines?)

blueyed opened this issue · 4 comments

Currently the following sync settings are used:

syn sync    minlines=50
syn sync    match zshHereDocSync    grouphere   NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)'
syn sync    match zshHereDocEndSync groupthere  NONE '^\s*EO\a\+\>'

I've noticed that this causes performance problems with larger files like Zsh's
Completion/Unix/Command/_git, which has ~6800 lines currently.

It helps to use syn synx maxlines=100 for it, but there's likely a better way to address this.

Check if this works better now. Is the syntax highlighting off now? You might also want to check, the output of :syntime report and report back which items are slow. Perhaps setting the 'regexp' engine for those items to one might also help

Thanks!

I was using maxlines=100 before, so it should be still good.

:syntime report shows these on the top, when scrolling the file:

  TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN
  6.204757   177371 20497   0.002289    0.000035  zshRedir           \d\=\(>\|>>\|>&\s*[0-9p-]\=\|&>\|>>&\|&>>\)[|!]\=
  4.671114   174365 2245    0.000461    0.000027  zshRedir           \d\=\(<\|<>\|<<<\|<&\s*[0-9p-]\=\)
  3.933100   183253 11554   0.014190    0.000021  zshVariableDef     \$\@<!\<\h\w*\[
  3.283801   221377 57377   0.001379    0.000015  zshOperator        ||\|&&\|;\|&!\=
  3.005503   212506 39853   0.002241    0.000014  zshVariableDef     \<\h\w*\ze+\==
  2.893611   174032 10429   0.002570    0.000017  zshComment         \%(^\|\s*\)#
  2.736086   224989 65150   0.002699    0.000012  zshNumber          [+-]\=\<\d\+\>
  2.574054   172721 0       0.001423    0.000015  zshNumber          [+-]\=\<0\o\+\>
  2.480148   172721 0       0.006613    0.000014  zshNumber          [+-]\=\<0x\x\+\>
  2.387601   172721 0       0.000245    0.000014  zshHereDoc         <\@<!<<-\s*\(["']\)\z(\S\+\)\1
  2.280400   174125 1444    0.000252    0.000013  zshCommands        \%(^\|\s\)[.:]\ze\s
  2.084219   172721 0       0.000193    0.000012  zshHereDoc         <\@<!<<\s*\(["']\)\z(\S\+\)\1
  2.049409   172843 164     0.001927    0.000012  zshNumber          [+-]\=\d\+\.\d\+\>
  2.040892   172721 0       0.012851    0.000012  zshHereDoc         <\@<!<<-\s*\\\=\z(\S\+\)
  2.013630   172721 0       0.010007    0.000012  zshHereDoc         <\@<!<<\s*\z([^<]\S*\)
  2.003800   172721 0       0.000863    0.000012  zshHereDoc         <\@<!<<\s*\\\z(\S\+\)
  1.920426   172721 0       0.003477    0.000011  zshNumber          [+-]\=\d\+#[-+]\=\w\+\>

Just for reference, I also had MyTodo and EOLWS in there (from my vimrc):

  5.439386   180713 7352    0.001094    0.000030  MyTodo             \v(FIXME|NOTE|TODO|OPTIMIZE|XXX):
  1.622549   173361 0       0.000493    0.000009  EOLWS              \s\+$

au Syntax * syn match MyTodo /\v(FIXME|NOTE|TODO|OPTIMIZE|XXX):/ containedin=ALL
hi def link MyTodo Todo

exec 'syn match EOLWS display excludenl /\s\+'
    \ . (mode == 'i' ? '\%#\@!' : '')
    \ . '$/ containedin=ALLBUT,EOLWSOK,EOLWS'

Edit: I've optimized the MyTodo to be:

au Syntax * syn match MyTodo /\v<(FIXME|NOTE|TODO|OPTIMIZE|XXX):/ containedin=.*Comment

Okay. I'll leave it like this for now.

Cool!

Also, thanks for stepping up as a maintainer for this!