@@ -33,16 +33,16 @@ endfunction
33
33
function ! indent_guides#enable ()
34
34
let g: indent_guides_autocmds_enabled = 1
35
35
36
- call indent_guides#init_buffer_vars ()
36
+ call indent_guides#init_script_vars ()
37
37
call indent_guides#highlight_colors ()
38
38
call indent_guides#clear_matches ()
39
39
40
40
" loop through each indent level and define a highlight pattern
41
41
" will automagically figure out whether to use tabs or spaces
42
- for l: level in range (1 , g: indent_guides_indent_levels )
42
+ for l: level in range (1 , s: indent_levels )
43
43
let l: group = ' IndentGuides' . ((l: level % 2 == 0 ) ? ' Even' : ' Odd' )
44
- let l: pattern = ' ^\s\{' . (l: level * b : indent_size - b : indent_size ) . ' \}\zs'
45
- let l: pattern .= ' \s\{' . b : guide_size . ' \}'
44
+ let l: pattern = ' ^\s\{' . (l: level * s : indent_size - s : indent_size ) . ' \}\zs'
45
+ let l: pattern .= ' \s\{' . s : guide_size . ' \}'
46
46
let l: pattern .= ' \ze'
47
47
48
48
" define the higlight pattern and add to list
@@ -78,7 +78,7 @@ endfunction
78
78
" Automagically calculates and defines the indent highlight colors.
79
79
"
80
80
function ! indent_guides#highlight_colors ()
81
- if g: indent_guides_auto_colors
81
+ if s: auto_colors
82
82
if has (' gui_running' )
83
83
call indent_guides#gui_highlight_colors ()
84
84
else
@@ -108,17 +108,17 @@ function! indent_guides#gui_highlight_colors()
108
108
let l: hi_normal_guibg = ' '
109
109
110
110
" capture the backgroud color from the normal highlight
111
- if b : hi_normal = ~ g: indent_guides_color_hex_guibg_pattern
111
+ if s : hi_normal = ~ s: color_hex_bg_pat
112
112
" hex color code is being used, eg. '#FFFFFF'
113
- let l: hi_normal_guibg = matchstr (b : hi_normal , g: indent_guides_color_hex_guibg_pattern )
113
+ let l: hi_normal_guibg = matchstr (s : hi_normal , s: color_hex_bg_pat )
114
114
115
- elseif b : hi_normal = ~ g: indent_guides_color_name_guibg_pattern
115
+ elseif s : hi_normal = ~ s: color_name_bg_pat
116
116
" color name is being used, eg. 'white'
117
- let l: color_name = matchstr (b : hi_normal , g: indent_guides_color_name_guibg_pattern )
117
+ let l: color_name = matchstr (s : hi_normal , s: color_name_bg_pat )
118
118
let l: hi_normal_guibg = color_helper#color_name_to_hex (l: color_name )
119
119
endif
120
120
121
- if l: hi_normal_guibg = ~ g: indent_guides_color_hex_pattern
121
+ if l: hi_normal_guibg = ~ s: color_hex_pat
122
122
" calculate the highlight background colors
123
123
let l: hi_odd_bg = indent_guides#lighten_or_darken_color (l: hi_normal_guibg )
124
124
let l: hi_even_bg = indent_guides#lighten_or_darken_color (l: hi_odd_bg )
@@ -135,12 +135,11 @@ endfunction
135
135
"
136
136
function ! indent_guides#lighten_or_darken_color (color )
137
137
let l: new_color = ' '
138
- let l: percent = g: indent_guides_color_change_percent / 100.0
139
138
140
139
if (&g: background == ' dark' )
141
- let l: new_color = color_helper#hex_color_lighten (a: color , l: percent )
140
+ let l: new_color = color_helper#hex_color_lighten (a: color , s: change_percent )
142
141
else
143
- let l: new_color = color_helper#hex_color_darken (a: color , l: percent )
142
+ let l: new_color = color_helper#hex_color_darken (a: color , s: change_percent )
144
143
endif
145
144
146
145
return l: new_color
@@ -165,10 +164,31 @@ endfunction
165
164
" We need to initialize these vars every time a buffer is entered while the
166
165
" plugin is enabled.
167
166
"
168
- function ! indent_guides#init_buffer_vars ()
169
- let b: indent_size = indent_guides#get_indent_size ()
170
- let b: guide_size = indent_guides#calculate_guide_size ()
171
- let b: hi_normal = indent_guides#capture_highlight (' Normal' )
167
+ function ! indent_guides#init_script_vars ()
168
+ let s: indent_size = indent_guides#get_indent_size ()
169
+ let s: guide_size = indent_guides#calculate_guide_size ()
170
+ let s: hi_normal = indent_guides#capture_highlight (' Normal' )
171
+
172
+ " shortcuts to the global variables - this makes the code easier to read
173
+ let s: debug = g: indent_guides_debug
174
+ let s: indent_levels = g: indent_guides_indent_levels
175
+ let s: auto_colors = g: indent_guides_auto_colors
176
+ let s: change_percent = g: indent_guides_color_change_percent / 100.0
177
+ let s: color_hex_pat = g: indent_guides_color_hex_pattern
178
+ let s: color_hex_bg_pat = g: indent_guides_color_hex_guibg_pattern
179
+ let s: color_name_bg_pat = g: indent_guides_color_name_guibg_pattern
180
+
181
+ if s: debug
182
+ echo ' s:indent_size = ' . s: indent_size
183
+ echo ' s:guide_size = ' . s: guide_size
184
+ echo ' s:hi_normal = ' . s: hi_normal
185
+ echo ' s:indent_levels = ' . s: indent_levels
186
+ echo ' s:auto_colors = ' . s: auto_colors
187
+ echo ' s:change_percent = ' . string (s: change_percent )
188
+ echo ' s:color_hex_pat = ' . s: color_hex_pat
189
+ echo ' s:color_hex_bg_pat = ' . s: color_hex_bg_pat
190
+ echo ' s:color_name_bg_pat = ' . s: color_name_bg_pat
191
+ endif
172
192
endfunction
173
193
174
194
"
@@ -182,9 +202,9 @@ function! indent_guides#calculate_guide_size()
182
202
let l: indent_size = indent_guides#get_indent_size ()
183
203
184
204
if l: indent_size > 1 && l: guide_size >= 1
185
- let l: guide_size = (l: guide_size > b : indent_size ) ? b : indent_size : l: guide_size
205
+ let l: guide_size = (l: guide_size > s : indent_size ) ? s : indent_size : l: guide_size
186
206
else
187
- let l: guide_size = b : indent_size
207
+ let l: guide_size = s : indent_size
188
208
endif
189
209
190
210
return l: guide_size
@@ -209,6 +229,7 @@ function! indent_guides#capture_highlight(group_name)
209
229
exe " silent hi " . a: group_name
210
230
redir END
211
231
232
+ let l: output = substitute (l: output , " \n " , " " , " " )
212
233
return l: output
213
234
endfunction
214
235
0 commit comments