Commits

abudden committed db7f5c4

Beginnings of project implementation.

Comments (0)

Files changed (5)

autoload/TagHighlight/BufferEntry.vim

 
 function! TagHighlight#BufferEntry#BufEnter(filename)
 
+	if ! exists('b:TagHighlightPrivate')
+		let b:TagHighlightPrivate = {}
+	endif
+	let b:TagHighlightPrivate['BufEnterInitialised'] = 1
 endfunction
 
 function! TagHighlight#BufferEntry#BufLeave(filename)
 
+	if ! exists('b:TagHighlightPrivate')
+		let b:TagHighlightPrivate = {}
+	endif
+	let b:TagHighlightPrivate['BufLeaveInitialised'] = 1
 endfunction

autoload/TagHighlight/Projects.vim

+" Tag Highlighter:
+"   Author:  A. S. Budden <abudden _at_ gmail _dot_ com>
+" Copyright: Copyright (C) 2013 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 || v:version < 700 || (exists('g:loaded_TagHLProjects') && (g:plugin_development_mode != 1))
+		throw "Already loaded"
+	endif
+catch
+	finish
+endtry
+let g:loaded_TagHLProjects = 1
+
+function! TagHighlight#Projects#GetProjects()
+	let projects = TagHighlight#Option#GetOption('Projects')
+	for project in keys(projects)
+		if type(projects[project]) == type("")
+			projects[project] = {'SourceDir': projects[project]}
+		elseif type(projects[project]) == type({}) && 
+					\ has_key(projects[project], 'SourceDir')
+			" Okay
+		else
+			call TagHLDebug("Invalid entry '".project."' in Projects list", "Warning")
+			call remove(projects, project)
+		endif
+	endfor
+	return projects
+endfunction
+
+function! TagHighlight#Projects#LoadProjectOptions(file)
+	let full_path = fnamemodify(a:file, ':p')
+	let projects = TagHighlight#Projects#GetProjects()
+	if ! exists('b:TagHighlightSettings')
+		let b:TagHighlightSettings = {}
+	endif
+
+	for name in keys(projects)
+		let project = projects[name]
+		if TagHighlight#Utilities#FileIsIn(full_path, project['SourceDir'])
+			let b:TagHighlightSettings = extend(b:TagHighlightSettings, project)
+		endif
+	endfor
+endfunction

autoload/TagHighlight/ReadTypes.vim

 
 	call TagHighlight#Option#LoadOptionFileIfPresent()
 
-	if len(a:suffix) == 0
-		return
-	endif
-
 	let file = expand('<afile>')
 	if len(file) == 0
 		let file = expand('%')
 	endif
 
+	call TagHighlight#Projects#LoadProjectOptions(file)
+
+	if len(a:suffix) == 0
+		return
+	endif
+
 	call TagHLDebug("Reading types of suffix " . a:suffix . " for file " . file, "Information")
 
 	if TagHighlight#Option#GetOption('DisableTypeParsing') == 1

autoload/TagHighlight/TagManager.vim

 	endfor
 	let &l:tags = newtagsoption
 endfunction
-
-function! TagHighlight#TagManager#GetProjects()
-	let projects = TagHighlight#Option#GetOption('Projects')
-	for project in keys(projects)
-		if type(projects[project]) == type("")
-			projects[project] = {'SourceDir': projects[project]}
-		elseif type(projects[project]) == type({}) && 
-					\ has_key(projects[project], 'SourceDir')
-			" Okay
-		else
-			call TagHLDebug("Invalid entry '".project."' in Projects list", "Warning")
-			call remove(projects, project)
-		endif
-	endfor
-	return projects
-endfunction

plugin/TagHighlight/data/options.txt

 # Vim-only options: #
 #####################
 
+projects:
+	VimOptionMap:Projects
+	Type:dict
+	Default:{}
+	Help:Project-specific configuration options.
+
 language_detection_method:
 	VimOptionMap:LanguageDetectionMethods
 	Type:list
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.