Commits

abudden committed 795c8c6

Added SetWorkingDir option.

Comments (0)

Files changed (3)

autoload/TagHighlight/ReadTypes.vim

 		exe 'call' postread_hook . '(fullname, a:suffix)'
 	endfor
 
+	if TagHighlight#Option#GetOption('SetWorkingDir') == 1
+		for entry in b:TagHighlightLoadedLibraries
+			if entry['Name'] == 'Local'
+				let lcdpath = fnamemodify(entry['Path'], ':h')
+				call TagHLDebug("Setting local working directory to " . lcdpath, "Information")
+				exe 'lcd' lcdpath
+				break
+			endif
+		endfor
+	endif
+
 	let reload_colours = TagHighlight#Option#GetOption('ReloadColourScheme')
 	if reload_colours
 		exe "colorscheme" g:colors_name

doc/TagHighlight.txt

 		PostUpdateHooks                  Link:|TagHL-PostUpdateHooks|
 			List of functions to call after updating types.
 
+		SetWorkingDir                    Link:|TagHL-SetWorkingDir|
+			When loading types highlighting, set the current directory.
+
 	Disabling built-in functionality:
 
 		DisableTypeParsing               Link:|TagHL-DisableTypeParsing|
 		I haven't got to the bottom of this bug, so am providing this
 		work-around as a fix in the meantime.
 
+		Option Type: Boolean
+		Default: False (don't reload colour scheme)
+
+	SetWorkingDir                        *TagHL-SetWorkingDir*
+		If this option is set to True or 1, the current working directory for
+		the buffer is set (using the |lcd| command) to the path containing the
+		types highlighting file.  This can be useful if you want your current
+		directory to be the root of a project regardless of how you open a
+		file.
+
+		Option Type: Boolean
+		Default: False (don't change current directory)
+
 	SkipPatterns                         *TagHL-SkipPatterns*
 		Any (python) regular expressions listed in this option will be matched
 		against any keyword names found in the tags file.  If they match, the
 	  called IgnoreFileScope disables this feature.
 	* New standard highlighting libraries: libc and libc++ (thanks to Kévin
 	  Brodsky for producing the scripts that generate these libraries).
+	* Added SetWorkingDir option to allow control of the working directory for
+	  a buffer with tags highlighted.
 	
 	Bug fixes:
 	

plugin/TagHighlight/data/options.txt

 	Default:False
 	Help:Reload the colour scheme after reading types file (in case colours don't work properly)
 
+set_working_dir:
+	VimOptionMap:SetWorkingDir
+	Type:bool
+	Default:False
+	Help:When loading a highlight file, set the working directory for the buffer to the types file path.
+
 ##########################
 # Python script options: #
 ##########################