1d9b152b2925401bdcd83d759365adcc5062ae44
[stack/conf/vim.git] / addons / TagHighlight / autoload / TagHighlight / TagManager.vim
1 " Tag Highlighter:
2 "   Author:  A. S. Budden <abudden _at_ gmail _dot_ com>
3 " Copyright: Copyright (C) 2009-2012 A. S. Budden
4 "            Permission is hereby granted to use and distribute this code,
5 "            with or without modifications, provided that this copyright
6 "            notice is copied with it. Like anything else that's free,
7 "            the TagHighlight plugin is provided *as is* and comes with no
8 "            warranty of any kind, either expressed or implied. By using
9 "            this plugin, you agree that in no event will the copyright
10 "            holder be liable for any damages resulting from the use
11 "            of this software.
12
13 " ---------------------------------------------------------------------
14 try
15         if &cp || v:version < 700 || (exists('g:loaded_TagHLTagManager') && (g:plugin_development_mode != 1))
16                 throw "Already loaded"
17         endif
18 catch
19         finish
20 endtry
21 let g:loaded_TagHLTagManager = 1
22
23 function! TagHighlight#TagManager#InitialiseBufferTags()
24         if ! has_key(g:TagHighlightPrivate, 'OriginalTagsSetting')
25                 let g:TagHighlightPrivate['OriginalTagsSetting'] = &g:tags
26         endif
27         if ! exists('b:TagHighlightPrivate')
28                 let b:TagHighlightPrivate = {}
29         endif
30         if ! has_key(b:TagHighlightPrivate, 'OriginalTagsSetting')
31                 let b:TagHighlightPrivate['OriginalTagsSetting'] = &tags
32         endif
33 endfunction
34
35 function! TagHighlight#TagManager#ConfigureTags()
36         if TagHighlight#Option#GetOption('DisableTagManager') == 1
37                 return
38         endif
39         let tagfilename = TagHighlight#Option#GetOption('TagFileName')
40         let tagfiles = []
41         for library in b:TagHighlightLoadedLibraries
42                 let types_folder = fnamemodify(library['Path'], ':h')
43                 let tag_file_path = types_folder . '/' . tagfilename
44                 if filereadable(tag_file_path)
45                         let tagfiles += [tag_file_path]
46                 endif
47         endfor
48
49         let newtagsoption = b:TagHighlightPrivate['OriginalTagsSetting']
50         for tagfile in tagfiles
51                 let newtagsoption .= ',' . escape(tagfile, ' ')
52         endfor
53         let &l:tags = newtagsoption
54 endfunction