Commits

abudden committed 5a169cb

Added initial version of a simple tag manager.

  • Participants
  • Parent commits bd876ec

Comments (0)

Files changed (4)

File autoload/TagHighlight/ReadTypes.vim

 " Tag Highlighter:
 "   Author:  A. S. Budden <abudden _at_ gmail _dot_ com>
-" Copyright: Copyright (C) 2009-2011 A. S. Budden
+" Copyright: Copyright (C) 2009-2012 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,
 function! s:ReadTypes(suffix)
 	let savedView = winsaveview()
 
+	call TagHighlight#TagManager#InitialiseBufferTags()
+
 	call TagHighlight#Option#LoadOptionFileIfPresent()
 
 	if len(a:suffix) == 0
 		let b:TagHighlightLoadedLibraries += [lib]
 	endfor
 
+	" Set up tags for all loaded libraries
+	call TagHighlight#TagManager#ConfigureTags()
+
 	" Handle any special cases
 	if has_key(g:TagHighlightPrivate['SpecialSyntaxHandlers'], a:suffix)
 		for handler in g:TagHighlightPrivate['SpecialSyntaxHandlers'][a:suffix]

File autoload/TagHighlight/TagManager.vim

+" Tag Highlighter:
+"   Author:  A. S. Budden <abudden _at_ gmail _dot_ com>
+" Copyright: Copyright (C) 2009-2012 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,
+"            the TagHighlight plugin 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_TagHLTagManager') && (g:plugin_development_mode != 1))
+		throw "Already loaded"
+	endif
+catch
+	finish
+endtry
+let g:loaded_TagHLTagManager = 1
+
+function! TagHighlight#TagManager#InitialiseBufferTags()
+	if ! has_key(g:TagHighlightPrivate, 'OriginalTagsSetting')
+		let g:TagHighlightPrivate['OriginalTagsSetting'] = &g:tags
+	endif
+	if ! exists('b:TagHighlightPrivate')
+		let b:TagHighlightPrivate = {}
+	endif
+	if ! has_key(b:TagHighlightPrivate, 'OriginalTagsSetting')
+		let b:TagHighlightPrivate['OriginalTagsSetting'] = &tags
+	endif
+endfunction
+
+function! TagHighlight#TagManager#ConfigureTags()
+	if TagHighlight#Option#GetOption('DisableTagManager') == 1
+		return
+	endif
+	let tagfilename = TagHighlight#Option#GetOption('TagFileName')
+	let tagfiles = []
+	for library in b:TagHighlightLoadedLibraries
+		let types_folder = fnamemodify(library['Path'], ':h')
+		let tag_file_path = types_folder . '/' . tagfilename
+		if filereadable(tag_file_path)
+			let tagfiles += [tag_file_path]
+		endif
+	endfor
+
+	let newtagsoption = b:TagHighlightPrivate['OriginalTagsSetting']
+	for tagfile in tagfiles
+		let newtagsoption .= ',' . escape(tagfile, ' ')
+	endfor
+	let &l:tags = newtagsoption
+endfunction

File doc/TagHighlight.txt

 		DisableTypeParsing               Link:|TagHL-DisableTypeParsing|
 		   Don't read types highlighter (disable highlight functionality).
 
+		DisableTagManager                Link: |TagHL-DisableTagManager|
+		   Don't automatically adjust the 'tags' option.
+
 		DoNotGenerateTags                Link:|TagHL-DoNotGenerateTags|
 		   Don't generate tags (use an existing tags file).
 
 		Option Type: Boolean
 		Default: False
 
+	DisableTagManager                     *TagHL-DisableTagManager*
+		The TagManager automatically sets up the 'tags' option to include the
+		generated tags file along with any tags files for user libraries (see
+		|TagHL-UserLibraries|).  This option can be used to disable the
+		TagManager.
+	
+		If the TagManager is enabled, the generated tags file will be added to
+		the 'tags' option; this makes it much easier to work with complex
+		directory structures while maintaining a common tags file.
+		If user libraries are configured and there is a tags file in the same
+		directory as the library .taghl file (with a filename that matches the
+		|TagHL-TagFileName| option), the TagManager will add the library tags
+		file to the 'tags' option to enable easy navigation to library source
+		code.
+
+		Option Type: Boolean
+		Default: False
+
 	DisableTypeParsing                   *TagHL-DisableTypeParsing*
 		This option disables loading of types highlighter files: no custom
 		types will be highlighted.
 							 fail very easily (and I've only used it for
 							 generating tags for its own source code!).  Added
 							 a reference (in the documentation) to the new
-							 wiki.
+							 wiki.  Added initial version of a manager for the
+							 'tags' option to automatically handle tag files
+							 for user libraries.
 
 2.1.5: 20th February 2012  : Added support for Scala (thanks to Lee Gauthier).
 

File plugin/TagHighlight/data/options.txt

 	Default:None
 	Help:Explicitly specified location for tag file (corresponding to Explicit search mode)
 
+disable_tag_manager:
+	VimOptionMap:DisableTagManager
+	Type:bool
+	Default:False
+	Help:Disable automatic management of tags option
+
 types_file_directory:
 	VimOptionMap:TypesFileDirectory
 	Type:string