Refactored the way global variables are initialized and added a new plugin option: g:indent_guides_indent_guide_size

This commit is contained in:
Nate Kane 2011-01-04 23:49:25 +10:00
parent d639a48f04
commit 538554b19f
2 changed files with 25 additions and 27 deletions

View File

@ -39,7 +39,7 @@ endfunction
function! color_helper#hex_color_to_rgb(hex_color) function! color_helper#hex_color_to_rgb(hex_color)
let l:rgb = [] let l:rgb = []
if a:hex_color =~ g:indent_guides_hex_color_pattern if a:hex_color =~ g:indent_guides_color_hex_pattern
let l:red = color_helper#hex_to_dec(strpart(a:hex_color, 1, 2)) let l:red = color_helper#hex_to_dec(strpart(a:hex_color, 1, 2))
let l:green = color_helper#hex_to_dec(strpart(a:hex_color, 3, 2)) let l:green = color_helper#hex_to_dec(strpart(a:hex_color, 3, 2))
let l:blue = color_helper#hex_to_dec(strpart(a:hex_color, 5, 2)) let l:blue = color_helper#hex_to_dec(strpart(a:hex_color, 5, 2))

View File

@ -24,34 +24,32 @@ command! IndentGuidesToggle call s:IndentGuidesToggle()
command! IndentGuidesEnable call s:IndentGuidesEnable() command! IndentGuidesEnable call s:IndentGuidesEnable()
command! IndentGuidesDisable call s:IndentGuidesDisable() command! IndentGuidesDisable call s:IndentGuidesDisable()
" Default options "
let g:indent_guides_indent_levels = " Initializes a given variable to a given value. The variable is only
\ exists('g:indent_guides_indent_levels') ? " initialized if it does not exist prior.
\ g:indent_guides_indent_levels : 30 "
function s:InitVariable(var, value)
let g:indent_guides_auto_colors = if !exists(a:var)
\ exists('g:indent_guides_auto_colors') ? if type(a:var) == type("")
\ g:indent_guides_auto_colors : 1 exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
else
let g:indent_guides_color_change_percent = exec 'let ' . a:var . ' = ' . a:value
\ exists('g:indent_guides_color_change_percent') ? endif
\ g:indent_guides_color_change_percent : 0.05 endif
endfunction
let g:indent_guides_debug =
\ exists('g:indent_guides_debug') ?
\ g:indent_guides_debug : 0
" Fixed global variables
let g:indent_guides_autocmds_enabled = 0 let g:indent_guides_autocmds_enabled = 0
let g:indent_guides_color_hex_pattern = '#[0-9A-Fa-f]\{6\}'
let g:indent_guides_color_hex_guibg_pattern = 'guibg=\zs' . g:indent_guides_color_hex_pattern . '\ze'
let g:indent_guides_color_name_guibg_pattern = "guibg='\\?\\zs[0-9A-Za-z ]\\+\\ze'\\?"
" " Configurable global variables
" Regex pattern for a hex color. call s:InitVariable('g:indent_guides_indent_levels', 30)
" call s:InitVariable('g:indent_guides_auto_colors', 1 )
" Example matches: call s:InitVariable('g:indent_guides_color_change_percent', 5 ) " ie. 5%
" - '#123ABC' call s:InitVariable('g:indent_guides_indent_guide_size', 0 )
" - '#ffffff' call s:InitVariable('g:indent_guides_debug', 0 )
" - '#000000'
"
let g:indent_guides_hex_color_pattern = '#[0-9A-Fa-f]\{6\}'
" Default mapping " Default mapping
nmap <Leader>ig :IndentGuidesToggle<CR> nmap <Leader>ig :IndentGuidesToggle<CR>