2 " Author: A. S. Budden <abudden _at_ gmail _dot_ com>
3 " Copyright: Copyright (C) 2009-2011 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
13 " ---------------------------------------------------------------------
15 if &cp || v:version < 700 || (exists('g:loaded_TagHLDebug') && (g:plugin_development_mode != 1))
16 throw "Already loaded"
21 let g:loaded_TagHLDebug = 1
23 let TagHighlight#Debug#DebugLevels = [
32 function! TagHighlight#Debug#GetDebugLevel()
34 let debug_level = TagHighlight#Option#GetOption('DebugLevel')
35 catch /Unrecognised option/
36 " Probably loading the option file, so no debug level available
37 " yet, so assume 'Information'
38 let debug_level = 'Information'
40 let debug_num = index(g:TagHighlight#Debug#DebugLevels, debug_level)
44 return index(g:TagHighlight#Debug#DebugLevels, 'Error')
48 function! TagHighlight#Debug#GetDebugLevelName()
49 let debug_level_num = TagHighlight#Debug#GetDebugLevel()
50 return g:TagHighlight#Debug#DebugLevels[debug_level_num]
53 function! TagHighlight#Debug#DebugLevelIncludes(level)
54 let level_index = index(g:TagHighlight#Debug#DebugLevels, a:level)
56 let level_index = index(g:TagHighlight#Debug#DebugLevels, 'Critical')
58 if level_index <= TagHighlight#Debug#GetDebugLevel()
65 function! TagHighlight#Debug#DebugUpdateTypesFile(filename)
66 " Update the types file with debugging turned on
67 if a:filename ==? 'None'
68 " Force case to be correct
69 let debug_file = 'None'
71 let debug_file = a:filename
74 let debug_options = ["DebugFile","DebugLevel"]
76 " Store the old debug options
77 for dbg_option in debug_options
78 let stored_option_name = 'Stored'.dbg_option
79 if has_key(g:TagHighlightSettings, dbg_option)
80 let g:TagHighlightSettings[stored_option_name] = g:TagHighlightSettings[dbg_option]
82 let g:TagHighlightSettings[stored_option_name] = 'None'
86 let g:TagHighlightSettings['DebugFile'] = debug_file
87 let g:TagHighlightSettings['DebugLevel'] = 'Information'
89 call TagHLDebug("========================================================", "Information")
90 redir => vim_version_info
93 call TagHLDebug("--------------------------------------------------------", "Information")
94 call TagHLDebug(vim_version_info, "Information")
95 call TagHighlight#Generation#UpdateAndRead(0)
97 " Get rid of the 'stored' versions of the debug options
98 for dbg_option in debug_options
99 let stored_option_name = 'Stored'.dbg_option
100 if g:TagHighlightSettings[stored_option_name] == 'None'
101 unlet g:TagHighlightSettings[dbg_option]
103 let g:TagHighlightSettings[dbg_option] = g:TagHighlightSettings[stored_option_name]
105 unlet g:TagHighlightSettings[stored_option_name]