From 6230f24254fefb7a73b02e1121fcc4173a59c842 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Tue, 29 Apr 2014 17:49:44 +0200 Subject: [PATCH 1/2] fix slow highlighter on vim 7.4 Uses "syntax keyword" instead of "keyword match" to find subjects to highlight, which is much faster. The problem is that the type of regex used by vim-easytags is a pathological bad case for the NFA regex engine which was introduced in vim 7.4. As reported here: https://groups.google.com/forum/#!topic/vim_dev/cPcMap1BdQw The patch was taken from the vim-easytags issues list on github, credit for it goes to @juliantaylor. --- misc/easytags/highlight.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/easytags/highlight.py b/misc/easytags/highlight.py index 6053726..a3dcac5 100644 --- a/misc/easytags/highlight.py +++ b/misc/easytags/highlight.py @@ -51,5 +51,5 @@ def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffi return ' | '.join(commands) def _easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax): - template = r'syntax match %s /%s\%%(%s\)%s/ containedin=ALLBUT,%s' - return template % (syntaxgroup, prefix, r'\|'.join(patterns), suffix, ignoresyntax) + template = r'syntax keyword %s %s containedin=ALLBUT,%s' + return template % (syntaxgroup, r' '.join(patterns), ignoresyntax) From f76d63e39d2c7d51e9c19e6848cc102f79a24112 Mon Sep 17 00:00:00 2001 From: Nicolas Hillegeer Date: Fri, 9 May 2014 23:28:39 +0200 Subject: [PATCH 2/2] apply slow highlighter fix to VimL implementation Not just for the python version anymore. It does help, the first highlight seems slow, but afterwards I can actually navigate a file without burning my house down, which is a huge improvement. --- autoload/xolox/easytags.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim index b639bbf..99a4186 100644 --- a/autoload/xolox/easytags.vim +++ b/autoload/xolox/easytags.vim @@ -462,9 +462,8 @@ function! xolox#easytags#highlight() " {{{2 if matches != [] " Convert matched tags to :syntax command and execute it. let matches = xolox#misc#list#unique(map(matches, 'xolox#misc#escape#pattern(get(v:val, "name"))')) - let pattern = tagkind.pattern_prefix . '\%(' . join(matches, '\|') . '\)' . tagkind.pattern_suffix - let template = 'syntax match %s /%s/ containedin=ALLBUT,%s' - let command = printf(template, hlgroup_tagged, escape(pattern, '/'), xolox#easytags#syntax_groups_to_ignore()) + let template = 'syntax keyword %s %s containedin=ALLBUT,%s' + let command = printf(template, hlgroup_tagged, join(matches, ' '), xolox#easytags#syntax_groups_to_ignore()) call xolox#misc#msg#debug("easytags.vim %s: Executing command '%s'.", g:xolox#easytags#version, command) try execute command