Refactored the way global variables are initialized and added a new plugin option: g:indent_guides_indent_guide_size
This commit is contained in:
parent
d639a48f04
commit
538554b19f
@ -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))
|
||||||
|
@ -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 =
|
|
||||||
\ exists('g:indent_guides_indent_levels') ?
|
|
||||||
\ g:indent_guides_indent_levels : 30
|
|
||||||
|
|
||||||
let g:indent_guides_auto_colors =
|
|
||||||
\ exists('g:indent_guides_auto_colors') ?
|
|
||||||
\ g:indent_guides_auto_colors : 1
|
|
||||||
|
|
||||||
let g:indent_guides_color_change_percent =
|
|
||||||
\ exists('g:indent_guides_color_change_percent') ?
|
|
||||||
\ g:indent_guides_color_change_percent : 0.05
|
|
||||||
|
|
||||||
let g:indent_guides_debug =
|
|
||||||
\ exists('g:indent_guides_debug') ?
|
|
||||||
\ g:indent_guides_debug : 0
|
|
||||||
|
|
||||||
let g:indent_guides_autocmds_enabled = 0
|
|
||||||
|
|
||||||
"
|
"
|
||||||
" Regex pattern for a hex color.
|
" Initializes a given variable to a given value. The variable is only
|
||||||
|
" initialized if it does not exist prior.
|
||||||
"
|
"
|
||||||
" Example matches:
|
function s:InitVariable(var, value)
|
||||||
" - '#123ABC'
|
if !exists(a:var)
|
||||||
" - '#ffffff'
|
if type(a:var) == type("")
|
||||||
" - '#000000'
|
exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
|
||||||
"
|
else
|
||||||
let g:indent_guides_hex_color_pattern = '#[0-9A-Fa-f]\{6\}'
|
exec 'let ' . a:var . ' = ' . a:value
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Fixed global variables
|
||||||
|
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
|
||||||
|
call s:InitVariable('g:indent_guides_indent_levels', 30)
|
||||||
|
call s:InitVariable('g:indent_guides_auto_colors', 1 )
|
||||||
|
call s:InitVariable('g:indent_guides_color_change_percent', 5 ) " ie. 5%
|
||||||
|
call s:InitVariable('g:indent_guides_indent_guide_size', 0 )
|
||||||
|
call s:InitVariable('g:indent_guides_debug', 0 )
|
||||||
|
|
||||||
" Default mapping
|
" Default mapping
|
||||||
nmap <Leader>ig :IndentGuidesToggle<CR>
|
nmap <Leader>ig :IndentGuidesToggle<CR>
|
||||||
|
Loading…
Reference in New Issue
Block a user