Syntax: Fasten highlighting, from 200ms to 20ms for first screen update

Problem:

The loading of a .md file was slow due to multiple nested lookback.
It is advised in vim help to prefer \zs, see :h /\@<
Anyway, it is useless to nest them.

089.080  000.085  000.085: sourcing /home/mtourneb/.vim/after/syntax/vimwiki.vim
089.264  005.184: opening buffers
089.322  000.058: BufEnter autocommands
089.323  000.001: editing files in windows
089.414  000.091: VimEnter autocommands
089.415  000.001: before starting main loop
303.698  214.283: first screen update
303.700  000.002: --- VIM STARTED ---

Solution:

Remove the function s:expand_delimiter in vars.vim.
It was doing a duplicate job with vimwiki#u#hi_expand_regex
And ... well avoid lookback as much as possible

091.784  000.087  000.087: sourcing /home/mtourneb/.vim/after/syntax/vimwiki.vim
091.991  006.034: opening buffers
092.050  000.059: BufEnter autocommands
092.052  000.002: editing files in windows
092.172  000.120: VimEnter autocommands
092.173  000.001: before starting main loop
112.574  020.401: first screen update
112.578  000.004: --- VIM STARTED ---
This commit is contained in:
Tinmarino
2023-03-18 01:45:02 -03:00
parent f4bd841a4c
commit 72d02207b0
5 changed files with 46 additions and 56 deletions
+6 -1
View File
@@ -7,10 +7,16 @@ Execute (Setup search testing wrapper):
Log 'Cheating for old vim version, do not want to reverse bug'
return
endif
" Execute command and grab output
redir => output
silent execute a:search_command
redir END
" The location list should not be empty
Assert !empty(getloclist(0)), a:test_name.": no location list result"
" The location list should contains entries
Assert match(output, '\d of \d') > -1, a:test_name.": no result message"
" Tests that VimwikiSearch is quoting the pattern correctly.
@@ -30,7 +36,6 @@ Execute (Search test wiki):
AssertEqual "= Test Wiki =", getline(1)
AssertEqual "vimwiki", &filetype
call TestSearch('VimwikiSearch foo', 'pattern with no spaces')
call TestSearch('VimwikiSearch foo bar', 'pattern with spaces')
call TestSearch('VimwikiSearch foo\bar', 'pattern with ''\''')
+3 -1
View File
@@ -37,6 +37,7 @@ Given vimwiki (Markdown typeface with escape sequence #1044: _ __ * ** {{{2):
a ~~staaill deleted~~ Del 9
$$Eq\$$ uation follows$ Math 10
`code \` not finished inline` Code 11
012345678901234567890
Execute (Set syntax markdown):
call SetSyntax('markdown')
@@ -48,7 +49,8 @@ Execute (Assert Syntax of escape typeface):
AssertEqual 'VimwikiBold4' , SyntaxAt(4, 14) . 4
AssertEqual 'VimwikiItalic5' , SyntaxAt(5, 14) . 5
" See: #1303 where an escape start can close the region
AssertEqual '6' , SyntaxAt(6, 14) . 6
" Fixed removing vars.vim::expand_delimiter
AssertEqual 'VimwikiItalic6' , SyntaxAt(6, 14) . 6
AssertEqual 'VimwikiSuperScript7', SyntaxAt(7, 14) . 7
AssertEqual 'VimwikiSubScript8' , SyntaxAt(8, 14) . 8
AssertEqual 'VimwikiDelText9' , SyntaxAt(9, 14) . 9
+2 -2
View File
@@ -623,8 +623,8 @@ Execute (Set Markdown):
Execute (Assert Syntax):
CommentLine 'Empty emphasis'
AssertEqual '', SyntaxAt(1, 1)
AssertEqual '', SyntaxAt(2, 1)
AssertEqual '1', SyntaxAt(1, 1) . 1
AssertEqual '2', SyntaxAt(2, 1) . 2
Given vimwiki (Typeface: https://github.github.com/gfm/#example-446):