From e3290ab006edf7c262a0bd117577043ce33435c6 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Sat, 29 Oct 2011 17:32:33 +0200 Subject: Make list of ignored syntax groups configurable While trying to fix issue #20 I decided to refactor the code that handles ignored syntax groups: Previously the list of excluded groups was hard coded in two places, now it's a configuration option. Then it turned out that including shFunction* in the list of excluded syntax groups didn't fix the reported issue... --- README.md | 4 ++++ autoload/xolox/easytags.vim | 10 ++++++---- doc/easytags.txt | 6 ++++++ misc/easytags/highlight.py | 14 +++++++------- plugin/easytags.vim | 6 +++++- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 036646c..a7b3d24 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,10 @@ If this is set and not false, it will suppress the warning on startup if ctags i :let g:easytags_suppress_ctags_warning = 1 +### The `g:easytags_ignored_syntax_groups` option + +This variable is a string of comma separated names of syntax groups in which dynamic highlighting is not applied. It defaults to `.*String.*,.*Comment.*,cIncluded`. + ## Faster syntax highlighting using Python The Vim script implementation of dynamic syntax highlighting is quite slow on large tags files. When the Python Interface to Vim is enabled the easytags plug-in will therefor automatically use a Python script that performs dynamic syntax highlighting about twice as fast as the Vim script implementation. The following options are available to change the default configuration. diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim index fa1e070..bd6cbaa 100644 --- a/autoload/xolox/easytags.vim +++ b/autoload/xolox/easytags.vim @@ -1,9 +1,9 @@ " Vim script " Author: Peter Odding -" Last Change: October 1, 2011 +" Last Change: October 29, 2011 " URL: http://peterodding.com/code/vim/easytags/ -let g:xolox#easytags#version = '2.7' +let g:xolox#easytags#version = '2.7.1' " Public interface through (automatic) commands. {{{1 @@ -315,8 +315,9 @@ function! xolox#easytags#highlight() " {{{2 " Convert matched tags to :syntax command and execute it. call map(matches, 'xolox#misc#escape#pattern(get(v:val, "name"))') let pattern = tagkind.pattern_prefix . '\%(' . join(xolox#misc#list#unique(matches), '\|') . '\)' . tagkind.pattern_suffix - let template = 'syntax match %s /%s/ containedin=ALLBUT,.*String.*,.*Comment.*,cIncluded' - let command = printf(template, hlgroup_tagged, escape(pattern, '/')) + let template = 'syntax match %s /%s/ containedin=ALLBUT,%s' + let command = printf(template, hlgroup_tagged, escape(pattern, '/'), xolox#misc#option#get('easytags_ignored_syntax_groups')) + call xolox#misc#msg#debug("easytags.vim %s: Executing command '%s'.", g:xolox#easytags#version, command) try execute command catch /^Vim\%((\a\+)\)\=:E339/ @@ -677,6 +678,7 @@ function! s:highlight_with_python(syntax_group, tagkind) " {{{2 let context['prefix'] = get(a:tagkind, 'pattern_prefix', '') let context['suffix'] = get(a:tagkind, 'pattern_suffix', '') let context['filters'] = get(a:tagkind, 'python_filter', {}) + let context['ignoresyntax'] = xolox#misc#option#get('easytags_ignored_syntax_groups') " Call the Python function and intercept the output. try redir => commands diff --git a/doc/easytags.txt b/doc/easytags.txt index fcc8593..372c541 100644 --- a/doc/easytags.txt +++ b/doc/easytags.txt @@ -321,6 +321,12 @@ is not found or not recent enough. > :let g:easytags_suppress_ctags_warning = 1 +------------------------------------------------------------------------------- +The *g:easytags_ignored_syntax_groups* option + +This variable is a string of comma separated names of syntax groups in which +dynamic highlighting is not applied. It defaults to '.*String.*,.*Comment.*,cIncluded'. + =============================================================================== *easytags-faster-syntax-highlighting-using-python* Faster syntax highlighting using Python ~ diff --git a/misc/easytags/highlight.py b/misc/easytags/highlight.py index b7a9cf3..154854e 100644 --- a/misc/easytags/highlight.py +++ b/misc/easytags/highlight.py @@ -5,7 +5,7 @@ syntax highlighting by reimplementing tag file reading and :syntax command generation in Python with a focus on doing the least amount of work. Author: Peter Odding -Last Change: June 14, 2011 +Last Change: October 29, 2011 URL: http://peterodding.com/code/vim/easytags ''' @@ -18,7 +18,7 @@ import sys def easytags_ping(): print 'it works!' -def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffix, filters): +def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffix, filters, ignoresyntax): # Get arguments from Vim. if filters: tagkinds = filters['kind'] @@ -43,13 +43,13 @@ def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffi patterns.append(escaped) counter += len(escaped) if counter > limit: - commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns)) + commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax)) patterns = [] counter = 0 if patterns: - commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns)) + commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax)) return ' | '.join(commands) -def _easytags_makecmd(syntaxgroup, prefix, suffix, patterns): - template = r'syntax match %s /%s\%%(%s\)%s/ containedin=ALLBUT,.*String.*,.*Comment.*,cIncluded' - return template % (syntaxgroup, prefix, r'\|'.join(patterns), suffix) +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) diff --git a/plugin/easytags.vim b/plugin/easytags.vim index d3624a5..344413e 100644 --- a/plugin/easytags.vim +++ b/plugin/easytags.vim @@ -1,6 +1,6 @@ " Vim plug-in " Author: Peter Odding -" Last Change: September 26, 2011 +" Last Change: October 29, 2011 " URL: http://peterodding.com/code/vim/easytags/ " Requires: Exuberant Ctags (http://ctags.sf.net) @@ -40,6 +40,10 @@ if !exists('g:easytags_ignored_filetypes') let g:easytags_ignored_filetypes = '^tex$' endif +if !exists('g:easytags_ignored_syntax_groups') + let g:easytags_ignored_syntax_groups = '.*String.*,.*Comment.*,cIncluded' +endif + if !exists('g:easytags_python_script') let g:easytags_python_script = expand(':p:h') . '/../misc/easytags/highlight.py' endif -- cgit v1.2.3