Commits

abudden committed 6433b4a

Added support for only updating types and tags if a types file exists.

This allows automatic regeneration of files as long as the projects are
small enough that the tags and types file generation is quick.

Comments (0)

Files changed (4)

autoload/TagHighlight/Find.vim

 				call TagHLDebug('File exists', 'Information')
 				let result['Exists'] = 1
 			else
-				call TagHLDebug('File does not exist', 'Information')
-				let result['Exists'] = 0
+				" Handle wildcards
+				let expansion = split(glob(result['FullPath'], 1), '\n')
+				let wildcard_match = 0
+				if len(expansion) > 0
+					for entry in expansion
+						if filereadable(entry)
+							let result['FullPath'] = entry
+							let result['Exists'] = 1
+							let wildcard_match = 1
+							break
+						endif
+					endfor
+				endif
+
+				if wildcard_match == 0
+					call TagHLDebug('File does not exist', 'Information')
+					let result['Exists'] = 0
+				endif
 			endif
 			break
 		endif

autoload/TagHighlight/Generation.vim

 		call TagHLDebug("Project config file does not exist", "Information")
 	endif
 	
-	" Call any PreUpdate hooks
-	let preupdate_hooks = TagHighlight#Option#GetOption('PreUpdateHooks')
-	for preupdate_hook in preupdate_hooks
-		call TagHLDebug("Calling pre-update hook " . preupdate_hook, "Information")
-		exe 'call' preupdate_hook . '()'
-	endfor
-	
 	" Most simple options are automatic.  The options below are
 	" handled manually.
 	
 		call TagHLDebug("Source dir set explicitly to " . TagHighlight#Option#GetOption("SourceDir"), "Information")
 	endif
 
+	" If a types file does not exist and this option is set, just quit now
+	if TagHighlight#Option#GetOption('OnlyGenerateTypesIfPresent') == 1
+		if types_file_info['Exists'] == 0
+			call TagHLDebug("Types file does not exist, not generating new files", "Information")
+			return
+		endif
+	endif
+
 	if tag_file_info['Exists'] == 1
 		if TagHighlight#Option#GetOption('DoNotGenerateTagsIfPresent') == 1
 			" This will be unset in UpdateAndRead
+			call TagHLDebug("Tag file doesn't exist and DoNotGenerateTagsIfPresent set, not generating new tag file", "Information")
 			let b:TagHighlightSettings['DoNotGenerateTags'] = 1
 		endif
 	elseif TagHighlight#Option#GetOption('DoNotGenerateTags') == 1
 		echoerr "Cannot create types file without generating tags: tags file does not exist"
 		return
 	endif
+
+	" Call any PreUpdate hooks
+	let preupdate_hooks = TagHighlight#Option#GetOption('PreUpdateHooks')
+	for preupdate_hook in preupdate_hooks
+		call TagHLDebug("Calling pre-update hook " . preupdate_hook, "Information")
+		exe 'call' preupdate_hook . '()'
+	endfor
 	
 	call TagHLDebug("Running generator with options:", "Information")
 	for var in ["g:TagHighlightSettings","b:TagHighlightConfigFileOptions","b:TagHighlightSettings"]

doc/TagHighlight.txt

 		DoNotGenerateTagsIfPresent       Link:|TagHL-DoNotGenerateTagsIfPresent|
 		   Don't generate tags if a tags file is detected.
 
+		OnlyGenerateTypesIfPresent      Link:|TagHL-OnlyGenerateTypesIfPresent|
+		   Only generate types or tags if a types file already exists.
+
 	How to Run Python and Ctags:
 
 		ForcedPythonVariant              Link:|TagHL-ForcedPythonVariant|
 		Option Type: Integer
 		Default: 0
 
+	OnlyGenerateTypesIfPresent           *TagHL-OnlyGenerateTypesIfPresent*
+		If this option is set, then a new types highlighter file will only be
+		generated if one already exists.  If working on relatively small
+		projects, this can be useful as you can set up an autocmd to
+		regenerate tags and types files when you save:
+>
+			let g:TagHighlightSettings['OnlyGenerateTypesIfPresent'] = 1
+			autocmd BufWritePost * UpdateTypesFile
+<
+		Every time you save a file, |TagHighlight| will check whether a types
+		file exists and if it does, it will regenerate it.  If it doesn't
+		exist, it will do nothing.  For larger projects, this is currently
+		probably not practical due to the time it takes ctags to process the
+		code.
+
+		Option Type: Boolean
+		Default: False (always generate types file)
+
 	ParsingSkipList                      *TagHL-ParsingSkipList*
 		If you're editing a lot of files and for most you want tag highlight
 		to run but one or two you don't, put the filenames of the ones for
 							 for user libraries (thanks to Alexey Radkov and
 							 Ali Hamdi).  Fixed a bug in the ParsingSkipList
 							 option implementation.  Added option to only
-							 generate the tags file if one is not present
+							 generate the tags file if one is not present or
+							 to only generate types file if one IS present
 							 (thanks to Ali Hamdi for the suggestion).
 
 2.1.5: 20th February 2012  : Added support for Scala (thanks to Lee Gauthier).

plugin/TagHighlight/data/options.txt

 	Default:.
 	Help:Location of user libraries that are specified with relative paths.
 
+use_existing_tagfile_if_present:
+	VimOptionMap:DoNotGenerateTagsIfPresent
+	Type:bool
+	Default:False
+	Help:Do not generate tags if a tag file already exists.
+
+only_generate_types_if_present:
+	VimOptionMap:OnlyGenerateTypesIfPresent
+	Type:bool
+	Default:False
+	Help:Only generate tags/types if a types file already exists.
+
 ##########################
 # Python script options: #
 ##########################
 	Default:False
 	Help:Do not generate tags: use an existing file
  
-use_existing_tagfile_if_present:
-	CommandLineSwitches:--use-existing-tagfile-if-present
-	VimOptionMap:DoNotGenerateTagsIfPresent
-	Type:bool
-	Default:False
-	Help:Do not generate tags if a tag file already exists
- 
 print_py_version:
 	CommandLineSwitches:--pyversion
 	Type:bool