Skip to content
This repository
Browse code

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...
  • Loading branch information...
commit e3290ab006edf7c262a0bd117577043ce33435c6 1 parent 3d7e091
Peter Odding authored October 29, 2011
4  README.md
Source Rendered
@@ -159,6 +159,10 @@ If this is set and not false, it will suppress the warning on startup if ctags i
159 159
 
160 160
     :let g:easytags_suppress_ctags_warning = 1
161 161
 
  162
+### The `g:easytags_ignored_syntax_groups` option
  163
+
  164
+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`.
  165
+
162 166
 ## Faster syntax highlighting using Python
163 167
 
164 168
 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.
10  autoload/xolox/easytags.vim
... ...
@@ -1,9 +1,9 @@
1 1
 " Vim script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: October 1, 2011
  3
+" Last Change: October 29, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 
6  
-let g:xolox#easytags#version = '2.7'
  6
+let g:xolox#easytags#version = '2.7.1'
7 7
 
8 8
 " Public interface through (automatic) commands. {{{1
9 9
 
@@ -315,8 +315,9 @@ function! xolox#easytags#highlight() " {{{2
315 315
             " Convert matched tags to :syntax command and execute it.
316 316
             call map(matches, 'xolox#misc#escape#pattern(get(v:val, "name"))')
317 317
             let pattern = tagkind.pattern_prefix . '\%(' . join(xolox#misc#list#unique(matches), '\|') . '\)' . tagkind.pattern_suffix
318  
-            let template = 'syntax match %s /%s/ containedin=ALLBUT,.*String.*,.*Comment.*,cIncluded'
319  
-            let command = printf(template, hlgroup_tagged, escape(pattern, '/'))
  318
+            let template = 'syntax match %s /%s/ containedin=ALLBUT,%s'
  319
+            let command = printf(template, hlgroup_tagged, escape(pattern, '/'), xolox#misc#option#get('easytags_ignored_syntax_groups'))
  320
+            call xolox#misc#msg#debug("easytags.vim %s: Executing command '%s'.", g:xolox#easytags#version, command)
320 321
             try
321 322
               execute command
322 323
             catch /^Vim\%((\a\+)\)\=:E339/
@@ -677,6 +678,7 @@ function! s:highlight_with_python(syntax_group, tagkind) " {{{2
677 678
     let context['prefix'] = get(a:tagkind, 'pattern_prefix', '')
678 679
     let context['suffix'] = get(a:tagkind, 'pattern_suffix', '')
679 680
     let context['filters'] = get(a:tagkind, 'python_filter', {})
  681
+    let context['ignoresyntax'] = xolox#misc#option#get('easytags_ignored_syntax_groups')
680 682
     " Call the Python function and intercept the output.
681 683
     try
682 684
       redir => commands
6  doc/easytags.txt
@@ -321,6 +321,12 @@ is not found or not recent enough.
321 321
 >
322 322
     :let g:easytags_suppress_ctags_warning = 1
323 323
 
  324
+-------------------------------------------------------------------------------
  325
+The *g:easytags_ignored_syntax_groups* option
  326
+
  327
+This variable is a string of comma separated names of syntax groups in which
  328
+dynamic highlighting is not applied. It defaults to '.*String.*,.*Comment.*,cIncluded'.
  329
+
324 330
 ===============================================================================
325 331
                               *easytags-faster-syntax-highlighting-using-python*
326 332
 Faster syntax highlighting using Python ~
14  misc/easytags/highlight.py
@@ -5,7 +5,7 @@
5 5
 generation in Python with a focus on doing the least amount of work.
6 6
 
7 7
 Author: Peter Odding <peter@peterodding.com>
8  
-Last Change: June 14, 2011
  8
+Last Change: October 29, 2011
9 9
 URL: http://peterodding.com/code/vim/easytags
10 10
 '''
11 11
 
@@ -18,7 +18,7 @@
18 18
 def easytags_ping():
19 19
     print 'it works!'
20 20
 
21  
-def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffix, filters):
  21
+def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffix, filters, ignoresyntax):
22 22
     # Get arguments from Vim.
23 23
     if filters:
24 24
         tagkinds = filters['kind']
@@ -43,13 +43,13 @@ def easytags_gensyncmd(tagsfiles, filetype, tagkinds, syntaxgroup, prefix, suffi
43 43
         patterns.append(escaped)
44 44
         counter += len(escaped)
45 45
         if counter > limit:
46  
-            commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns))
  46
+            commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax))
47 47
             patterns = []
48 48
             counter = 0
49 49
     if patterns:
50  
-        commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns))
  50
+        commands.append(_easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax))
51 51
     return ' | '.join(commands)
52 52
 
53  
-def _easytags_makecmd(syntaxgroup, prefix, suffix, patterns):
54  
-    template = r'syntax match %s /%s\%%(%s\)%s/ containedin=ALLBUT,.*String.*,.*Comment.*,cIncluded'
55  
-    return template % (syntaxgroup, prefix, r'\|'.join(patterns), suffix)
  53
+def _easytags_makecmd(syntaxgroup, prefix, suffix, patterns, ignoresyntax):
  54
+    template = r'syntax match %s /%s\%%(%s\)%s/ containedin=ALLBUT,%s'
  55
+    return template % (syntaxgroup, prefix, r'\|'.join(patterns), suffix, ignoresyntax)
6  plugin/easytags.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: September 26, 2011
  3
+" Last Change: October 29, 2011
4 4
 " URL: http://peterodding.com/code/vim/easytags/
5 5
 " Requires: Exuberant Ctags (http://ctags.sf.net)
6 6
 
@@ -40,6 +40,10 @@ if !exists('g:easytags_ignored_filetypes')
40 40
   let g:easytags_ignored_filetypes = '^tex$'
41 41
 endif
42 42
 
  43
+if !exists('g:easytags_ignored_syntax_groups')
  44
+  let g:easytags_ignored_syntax_groups = '.*String.*,.*Comment.*,cIncluded'
  45
+endif
  46
+
43 47
 if !exists('g:easytags_python_script')
44 48
   let g:easytags_python_script = expand('<sfile>:p:h') . '/../misc/easytags/highlight.py'
45 49
 endif

0 notes on commit e3290ab

Please sign in to comment.
Something went wrong with that request. Please try again.