|
1 | 1 | " Vim script |
2 | 2 | " Author: Peter Odding <peter@peterodding.com> |
3 | | -" Last Change: June 19, 2013 |
| 3 | +" Last Change: June 20, 2013 |
4 | 4 | " URL: http://peterodding.com/code/vim/easytags/ |
5 | 5 |
|
6 | | -let g:xolox#easytags#version = '3.3.8' |
| 6 | +let g:xolox#easytags#version = '3.3.9' |
7 | 7 |
|
8 | 8 | " Public interface through (automatic) commands. {{{1 |
9 | 9 |
|
@@ -383,7 +383,7 @@ function! xolox#easytags#highlight() " {{{2 |
383 | 383 | let matches = xolox#misc#list#unique(map(matches, 'xolox#misc#escape#pattern(get(v:val, "name"))')) |
384 | 384 | let pattern = tagkind.pattern_prefix . '\%(' . join(matches, '\|') . '\)' . tagkind.pattern_suffix |
385 | 385 | let template = 'syntax match %s /%s/ containedin=ALLBUT,%s' |
386 | | - let command = printf(template, hlgroup_tagged, escape(pattern, '/'), xolox#misc#option#get('easytags_ignored_syntax_groups')) |
| 386 | + let command = printf(template, hlgroup_tagged, escape(pattern, '/'), xolox#easytags#syntax_groups_to_ignore()) |
387 | 387 | call xolox#misc#msg#debug("easytags.vim %s: Executing command '%s'.", g:xolox#easytags#version, command) |
388 | 388 | try |
389 | 389 | execute command |
@@ -670,6 +670,32 @@ function! xolox#easytags#get_tagsfile() " {{{2 |
670 | 670 | return tagsfile |
671 | 671 | endfunction |
672 | 672 |
|
| 673 | +function! xolox#easytags#syntax_groups_to_ignore() " {{{2 |
| 674 | + " Get a string matching the syntax groups where dynamic highlighting should |
| 675 | + " *not* apply. This is complicated by the fact that Vim has a tendency to do |
| 676 | + " this: |
| 677 | + " |
| 678 | + " Vim(syntax):E409: Unknown group name: doxygen.* |
| 679 | + " |
| 680 | + " This happens when a group wildcard doesn't match *anything*. Why does Vim |
| 681 | + " always have to make everything so complicated? :-( |
| 682 | + let groups = ['.*String.*', '.*Comment.*'] |
| 683 | + for group_name in ['cIncluded', 'cCppOut2', 'cCppInElse2', 'cCppOutIf2'] |
| 684 | + if hlexists(group_name) |
| 685 | + call add(groups, group_name) |
| 686 | + endif |
| 687 | + endfor |
| 688 | + " Doxygen is an "add-on syntax script", it's usually used in combination: |
| 689 | + " :set syntax=c.doxygen |
| 690 | + " It gets special treatment because it defines a dozen or so groups :-) |
| 691 | + if hlexists('doxygenComment') |
| 692 | + call add(groups, 'doxygen.*') |
| 693 | + endif |
| 694 | + return join(groups, ',') |
| 695 | +filetype |
| 696 | + |
| 697 | +endfunction |
| 698 | + |
673 | 699 | " Public API for definition of file type specific dynamic syntax highlighting. {{{1 |
674 | 700 |
|
675 | 701 | function! xolox#easytags#define_tagkind(object) " {{{2 |
@@ -780,7 +806,7 @@ function! s:highlight_with_python(syntax_group, tagkind) " {{{2 |
780 | 806 | let context['prefix'] = get(a:tagkind, 'pattern_prefix', '') |
781 | 807 | let context['suffix'] = get(a:tagkind, 'pattern_suffix', '') |
782 | 808 | let context['filters'] = get(a:tagkind, 'python_filter', {}) |
783 | | - let context['ignoresyntax'] = xolox#misc#option#get('easytags_ignored_syntax_groups') |
| 809 | + let context['ignoresyntax'] = xolox#easytags#syntax_groups_to_ignore() |
784 | 810 | " Call the Python function and intercept the output. |
785 | 811 | try |
786 | 812 | redir => commands |
|
0 commit comments