diff options
author | Peter Odding <peter@peterodding.com> | 2013-06-20 00:24:00 +0200 |
---|---|---|
committer | Peter Odding <peter@peterodding.com> | 2013-06-20 00:24:00 +0200 |
commit | 5cf3313d0950e32ffd1d2f75b891f4ccc2aa7aa3 (patch) | |
tree | 3a3a75b15cfa3b81a42be405a49e6cc0a3113e10 | |
parent | 28e2b55061fc5dcb6b1f78c002780e0dd7d2e637 (diff) | |
download | vim-easytags-5cf3313d0950e32ffd1d2f75b891f4ccc2aa7aa3.tar.gz |
Improve handling of ignored syntax groups (issue #57)
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | autoload/xolox/easytags.vim | 34 | ||||
-rw-r--r-- | doc/easytags.txt | 8 | ||||
-rw-r--r-- | plugin/easytags.vim | 6 |
4 files changed, 33 insertions, 19 deletions
@@ -205,10 +205,6 @@ 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`. - ## Customizing the easytags plug-in Advanced users may wish to customize how the easytags plug-in works beyond the point of changing configuration defaults. This section contains some hints about this. If you have suggestions, please feel free to submit them. diff --git a/autoload/xolox/easytags.vim b/autoload/xolox/easytags.vim index 92772cd..a484421 100644 --- a/autoload/xolox/easytags.vim +++ b/autoload/xolox/easytags.vim @@ -1,9 +1,9 @@ " Vim script " Author: Peter Odding <peter@peterodding.com> -" Last Change: June 19, 2013 +" Last Change: June 20, 2013 " URL: http://peterodding.com/code/vim/easytags/ -let g:xolox#easytags#version = '3.3.8' +let g:xolox#easytags#version = '3.3.9' " Public interface through (automatic) commands. {{{1 @@ -383,7 +383,7 @@ function! xolox#easytags#highlight() " {{{2 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#misc#option#get('easytags_ignored_syntax_groups')) + let command = printf(template, hlgroup_tagged, escape(pattern, '/'), 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 @@ -670,6 +670,32 @@ function! xolox#easytags#get_tagsfile() " {{{2 return tagsfile endfunction +function! xolox#easytags#syntax_groups_to_ignore() " {{{2 + " Get a string matching the syntax groups where dynamic highlighting should + " *not* apply. This is complicated by the fact that Vim has a tendency to do + " this: + " + " Vim(syntax):E409: Unknown group name: doxygen.* + " + " This happens when a group wildcard doesn't match *anything*. Why does Vim + " always have to make everything so complicated? :-( + let groups = ['.*String.*', '.*Comment.*'] + for group_name in ['cIncluded', 'cCppOut2', 'cCppInElse2', 'cCppOutIf2'] + if hlexists(group_name) + call add(groups, group_name) + endif + endfor + " Doxygen is an "add-on syntax script", it's usually used in combination: + " :set syntax=c.doxygen + " It gets special treatment because it defines a dozen or so groups :-) + if hlexists('doxygenComment') + call add(groups, 'doxygen.*') + endif + return join(groups, ',') +filetype + +endfunction + " Public API for definition of file type specific dynamic syntax highlighting. {{{1 function! xolox#easytags#define_tagkind(object) " {{{2 @@ -780,7 +806,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') + let context['ignoresyntax'] = xolox#easytags#syntax_groups_to_ignore() " Call the Python function and intercept the output. try redir => commands diff --git a/doc/easytags.txt b/doc/easytags.txt index 6ae6516..3d762be 100644 --- a/doc/easytags.txt +++ b/doc/easytags.txt @@ -26,7 +26,6 @@ Contents ~ 14. The |g:easytags_include_members| option 15. The |g:easytags_resolve_links| option 16. The |g:easytags_suppress_ctags_warning| option - 17. The |g:easytags_ignored_syntax_groups| option 5. Customizing the easytags plug-in |customizing-easytags-plug-in| 1. Passing custom command line arguments to Exuberant Ctags |easytags-passing-custom-command-line-arguments-to-exuberant-ctags| 2. Update & highlight tags immediately after save |easytags-update-highlight-tags-immediately-after-save| @@ -443,13 +442,6 @@ 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'. - =============================================================================== *customizing-easytags-plug-in* Customizing the easytags plug-in ~ diff --git a/plugin/easytags.vim b/plugin/easytags.vim index d3ba579..d7033cf 100644 --- a/plugin/easytags.vim +++ b/plugin/easytags.vim @@ -1,6 +1,6 @@ " Vim plug-in " Author: Peter Odding <peter@peterodding.com> -" Last Change: June 19, 2013 +" Last Change: June 20, 2013 " URL: http://peterodding.com/code/vim/easytags/ " Requires: Exuberant Ctags (http://ctags.sf.net) @@ -40,8 +40,8 @@ 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,cCppInElse2,cCppOutIf2,cCppOut2,doxygen.*' +if exists('g:easytags_ignored_syntax_groups') + call xolox#misc#msg#warn("easytags.vim %s: The 'g:easytags_ignored_syntax_groups' option is no longer supported. It has been moved back into the code base for more flexible handling at runtime.", g:xolox#easytags#version) endif if !exists('g:easytags_python_script') |