Permalink
Browse files

Improve handling of ignored syntax groups (issue #57)

  • Loading branch information...
1 parent 28e2b55 commit 5cf3313d0950e32ffd1d2f75b891f4ccc2aa7aa3 @xolox committed Jun 19, 2013
Showing with 33 additions and 19 deletions.
  1. +0 −4 README.md
  2. +30 −4 autoload/xolox/easytags.vim
  3. +0 −8 doc/easytags.txt
  4. +3 −3 plugin/easytags.vim
View
@@ -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.
@@ -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
View
@@ -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 ~
View
@@ -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')

0 comments on commit 5cf3313

Please sign in to comment.