Commits

abudden committed ca779a7

Moved cluster handlers out of the .taghl files and into the Vim code. This is handled with some special handlers that are language specific. Fixes #51.

Comments (0)

Files changed (5)

autoload/TagHighlight/ReadTypes.vim

 		exe 'so' fname
 	endfor
 
+	" Handle any special cases
+	if has_key(g:TagHighlightPrivate['SpecialSyntaxHandlers'], a:suffix)
+		for handler in g:TagHighlightPrivate['SpecialSyntaxHandlers'][a:suffix]
+			exe 'call' handler . '()'
+		endfor
+	endif
+
 	" Restore the view
 	call winrestview(savedView)
 endfunction

autoload/TagHighlight/SpecialHandlers.vim

+" Tag Highlighter:
+"   Author:  A. S. Budden <abudden _at_ gmail _dot_ com>
+"   Date:    14/07/2011
+"   Version: 1
+" Copyright: Copyright (C) 2011 A. S. Budden
+"            Permission is hereby granted to use and distribute this code,
+"            with or without modifications, provided that this copyright
+"            notice is copied with it. Like anything else that's free,
+"            SpecialHandlers.vim is provided *as is* and comes with no
+"            warranty of any kind, either expressed or implied. By using
+"            this plugin, you agree that in no event will the copyright
+"            holder be liable for any damages resulting from the use
+"            of this software.
+
+" ---------------------------------------------------------------------
+try
+	if &cp || (exists('g:loaded_TagHLSpecialHandlers') && (g:plugin_development_mode != 1))
+		throw "Already loaded"
+	endif
+catch
+	finish
+endtry
+let g:loaded_TagHLSpecialHandlers = 1
+
+function! TagHighlight#SpecialHandlers#CRainbowHandler()
+	if exists("b:hlrainbow") && ! exists("g:nohlrainbow")
+		" Use a dictionary as a set (a unique item list)
+		let hl_dict = {}
+		for key in ["c","c++"]
+			if has_key(g:TagHighlightPrivate['Kinds'], key)
+				for kind in values(g:TagHighlightPrivate['Kinds'][key])
+					let hl_dict[kind] = ""
+				endfor
+			endif
+		endfor
+		let all_kinds = keys(hl_dict)
+		for cluster in ["cBracketGroup","cCppBracketGroup","cCurlyGroup","cParenGroup","cCppParenGroup"]
+			exe 'syn cluster' cluster 'add=' . join(all_kinds, ',')
+		endfor
+	endif
+endfunction
+
+function! TagHighlight#SpecialHandlers#JavaTopHandler()
+	if has_key(g:TagHighlightPrivate['Kinds']['java']
+		exe 'syn cluster javaTop add=' . join(values(g:TagHighlightPrivate['Kinds']['java']), ',')
+	endif
+endfunction

plugin/TagHighlight/data/languages/c.txt

 VimExtensionMatcher:\(c\|cc\|cpp\|h\|hpp\|cxx\|hxx\)
 Suffix:c
 SkipList:p
+SpecialSyntaxHandlers:TagHighlight#SpecialHandlers#CRainbowHandler
 
 # vim: ff=unix:noet

plugin/TagHighlight/data/languages/java.txt

 PythonExtensionMatcher:java
 VimExtensionMatcher:java
 Suffix:java
+SpecialSyntaxHandlers:TagHighlight#SpecialHandlers#JavaTopHandler
 
 # vim: ff=unix:noet

plugin/TagHighlight/module/generation.py

     vimtypes_entries.append('')
     vimtypes_entries += matchEntries
 
-    AddList = 'add='
-    for thisType in allTypes:
-        if thisType in typesUsedByLanguage:
-            if AddList != 'add=':
-                AddList += ','
-            AddList += thisType
-
     if options['include_locals']:
         LocalTagType = ',CTagsLocalVariable'
     else:
         LocalTagType = ''
 
-    if language in ['c',]:
-        vimtypes_entries.append('')
-        vimtypes_entries.append("if exists('b:hlrainbow') && !exists('g:nohlrainbow')")
-        vimtypes_entries.append('\tsyn cluster cBracketGroup ' + AddList + LocalTagType)
-        vimtypes_entries.append('\tsyn cluster cCppBracketGroup ' + AddList + LocalTagType)
-        vimtypes_entries.append('\tsyn cluster cCurlyGroup ' + AddList + LocalTagType)
-        vimtypes_entries.append('\tsyn cluster cParenGroup ' + AddList + LocalTagType)
-        vimtypes_entries.append('\tsyn cluster cCppParenGroup ' + AddList + LocalTagType)
-        vimtypes_entries.append('endif')
-    if language in ['java',]:
-        vimtypes_entries.append('')
-        vimtypes_entries.append('syn cluster javaTop ' + AddList + LocalTagType)
-
     if options['types_file_name_override'] is not None and options['types_file_name_override'] != 'None':
         type_file_name = options['types_file_name_override']
     else:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.