Skip to content

Commit 5cf3313

Browse files
committed
Improve handling of ignored syntax groups (issue #57)
1 parent 28e2b55 commit 5cf3313

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ If this is set and not false, it will suppress the warning on startup if ctags i
205205

206206
:let g:easytags_suppress_ctags_warning = 1
207207

208-
### The `g:easytags_ignored_syntax_groups` option
209-
210-
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`.
211-
212208
## Customizing the easytags plug-in
213209

214210
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.

autoload/xolox/easytags.vim

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 19, 2013
3+
" Last Change: June 20, 2013
44
" URL: http://peterodding.com/code/vim/easytags/
55

6-
let g:xolox#easytags#version = '3.3.8'
6+
let g:xolox#easytags#version = '3.3.9'
77

88
" Public interface through (automatic) commands. {{{1
99

@@ -383,7 +383,7 @@ function! xolox#easytags#highlight() " {{{2
383383
let matches = xolox#misc#list#unique(map(matches, 'xolox#misc#escape#pattern(get(v:val, "name"))'))
384384
let pattern = tagkind.pattern_prefix . '\%(' . join(matches, '\|') . '\)' . tagkind.pattern_suffix
385385
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())
387387
call xolox#misc#msg#debug("easytags.vim %s: Executing command '%s'.", g:xolox#easytags#version, command)
388388
try
389389
execute command
@@ -670,6 +670,32 @@ function! xolox#easytags#get_tagsfile() " {{{2
670670
return tagsfile
671671
endfunction
672672

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+
673699
" Public API for definition of file type specific dynamic syntax highlighting. {{{1
674700

675701
function! xolox#easytags#define_tagkind(object) " {{{2
@@ -780,7 +806,7 @@ function! s:highlight_with_python(syntax_group, tagkind) " {{{2
780806
let context['prefix'] = get(a:tagkind, 'pattern_prefix', '')
781807
let context['suffix'] = get(a:tagkind, 'pattern_suffix', '')
782808
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()
784810
" Call the Python function and intercept the output.
785811
try
786812
redir => commands

doc/easytags.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Contents ~
2626
14. The |g:easytags_include_members| option
2727
15. The |g:easytags_resolve_links| option
2828
16. The |g:easytags_suppress_ctags_warning| option
29-
17. The |g:easytags_ignored_syntax_groups| option
3029
5. Customizing the easytags plug-in |customizing-easytags-plug-in|
3130
1. Passing custom command line arguments to Exuberant Ctags |easytags-passing-custom-command-line-arguments-to-exuberant-ctags|
3231
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.
443442
>
444443
:let g:easytags_suppress_ctags_warning = 1
445444
<
446-
-------------------------------------------------------------------------------
447-
The *g:easytags_ignored_syntax_groups* option
448-
449-
This variable is a string of comma separated names of syntax groups in which
450-
dynamic highlighting is not applied. It defaults to
451-
'.*String.*,.*Comment.*,cIncluded'.
452-
453445
===============================================================================
454446
*customizing-easytags-plug-in*
455447
Customizing the easytags plug-in ~

plugin/easytags.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 19, 2013
3+
" Last Change: June 20, 2013
44
" URL: http://peterodding.com/code/vim/easytags/
55
" Requires: Exuberant Ctags (http://ctags.sf.net)
66

@@ -40,8 +40,8 @@ if !exists('g:easytags_ignored_filetypes')
4040
let g:easytags_ignored_filetypes = '^tex$'
4141
endif
4242

43-
if !exists('g:easytags_ignored_syntax_groups')
44-
let g:easytags_ignored_syntax_groups = '.*String.*,.*Comment.*,cIncluded,cCppInElse2,cCppOutIf2,cCppOut2,doxygen.*'
43+
if exists('g:easytags_ignored_syntax_groups')
44+
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)
4545
endif
4646

4747
if !exists('g:easytags_python_script')

0 commit comments

Comments
 (0)