Skip to content

Commit

Permalink
perf: improve syntax performance again
Browse files Browse the repository at this point in the history
refer: #2877
  • Loading branch information
lervag committed Jan 28, 2024
1 parent a397999 commit c08aea6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions autoload/vimtex/syntax/core.vim
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ function! vimtex#syntax#core#init_rules() abort " {{{1

syntax match texLigature "--"
syntax match texLigature "---"
syntax match texLigature "``\|''\|,,"
syntax match texLigature "\([`',]\)\1"
syntax match texTabularChar "&"
syntax match texTabularChar "\\\\"

" E.g.: \$ \& \% \# \{ \} \_ \S \P
syntax match texSpecialChar "\\\@<!\~"
syntax match texSpecialChar "\~"
syntax match texSpecialChar "\\ "
syntax match texSpecialChar "\\[$&%#{}_@]"
syntax match texSpecialChar "\\[SP@]\ze[^a-zA-Z@]"
Expand Down Expand Up @@ -2174,7 +2174,7 @@ endfunction

" }}}1
function! s:match_conceal_spacing() abort " {{{1
syntax match texSpecialChar "\\\@<!\~" conceal cchar=
syntax match texSpecialChar "\~" conceal cchar=
syntax match texSpecialChar "\\ " conceal cchar=
syntax match texSpecialChar "\\[,;:!>]" conceal
syntax match texSpecialChar "\\@\ze\s\+" conceal
Expand Down
3 changes: 3 additions & 0 deletions test/test-syntax/test-core.tex
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@ \section*{Acknowledgement}
0
\end{tabular}
%% Some basic stuff re. #2877
foo\\~bar \~More test; in math: $f(x) ~ \~ 1$
\end{document}
4 changes: 4 additions & 0 deletions test/test-syntax/test-core.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ call assert_true(vimtex#syntax#in('texCmdBibitem', 124, 3))
call assert_true(vimtex#syntax#in('texBibitemArg', 124, 13))
call assert_true(vimtex#syntax#in('texBibitemOpt', 125, 13))

call assert_true(vimtex#syntax#in('texTabularChar', 133, 5))
call assert_true(vimtex#syntax#in('texSpecialChar', 133, 6))
call assert_true(vimtex#syntax#in('texCmdAccent', 133, 11))

call vimtex#test#finished()

0 comments on commit c08aea6

Please sign in to comment.