2010-12-07 04:41:05 -05:00
|
|
|
" Author: Nate Kane <nathanaelkane AT gmail DOT com>
|
|
|
|
" Homepage: http://github.com/nathanaelkane/vim-indent-guides
|
|
|
|
|
2015-10-26 05:10:24 -04:00
|
|
|
" Do not load if vim is too old
|
2015-10-25 07:10:51 -04:00
|
|
|
if (v:version == 701 && ! exists('*matchadd')) || (v:version < 701)
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2010-12-20 06:51:02 -05:00
|
|
|
if exists('g:loaded_indent_guides') || &cp
|
2010-12-11 07:59:10 -05:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_indent_guides = 1
|
2010-12-20 07:26:45 -05:00
|
|
|
call indent_guides#define_default_highlights()
|
2010-12-11 07:59:10 -05:00
|
|
|
|
2010-12-07 04:41:05 -05:00
|
|
|
function! s:IndentGuidesToggle()
|
|
|
|
call indent_guides#toggle()
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! s:IndentGuidesEnable()
|
|
|
|
call indent_guides#enable()
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! s:IndentGuidesDisable()
|
|
|
|
call indent_guides#disable()
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Commands
|
2011-02-17 16:29:34 -05:00
|
|
|
command! -bar IndentGuidesToggle call s:IndentGuidesToggle()
|
|
|
|
command! -bar IndentGuidesEnable call s:IndentGuidesEnable()
|
|
|
|
command! -bar IndentGuidesDisable call s:IndentGuidesDisable()
|
2010-12-07 04:41:05 -05:00
|
|
|
|
2010-12-09 07:45:09 -05:00
|
|
|
"
|
2011-01-04 08:49:25 -05:00
|
|
|
" Initializes a given variable to a given value. The variable is only
|
|
|
|
" initialized if it does not exist prior.
|
2010-12-09 07:45:09 -05:00
|
|
|
"
|
2011-01-04 08:49:25 -05:00
|
|
|
function s:InitVariable(var, value)
|
|
|
|
if !exists(a:var)
|
2011-02-21 14:23:21 -05:00
|
|
|
if type(a:value) == type("")
|
2011-01-04 08:49:25 -05:00
|
|
|
exec 'let ' . a:var . ' = ' . "'" . a:value . "'"
|
|
|
|
else
|
|
|
|
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
|
2013-06-27 05:14:53 -04:00
|
|
|
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', 10) " ie. 10%
|
|
|
|
call s:InitVariable('g:indent_guides_guide_size', 0)
|
|
|
|
call s:InitVariable('g:indent_guides_start_level', 1)
|
|
|
|
call s:InitVariable('g:indent_guides_enable_on_vim_startup', 0)
|
|
|
|
call s:InitVariable('g:indent_guides_debug', 0)
|
|
|
|
call s:InitVariable('g:indent_guides_space_guides', 1)
|
|
|
|
call s:InitVariable('g:indent_guides_soft_pattern', '\s')
|
2013-06-27 05:43:10 -04:00
|
|
|
call s:InitVariable('g:indent_guides_default_mapping', 1)
|
2010-12-09 07:45:09 -05:00
|
|
|
|
2013-03-06 06:57:33 -05:00
|
|
|
if !exists('g:indent_guides_exclude_filetypes')
|
|
|
|
let g:indent_guides_exclude_filetypes = ['help']
|
|
|
|
endif
|
|
|
|
|
2010-12-07 04:41:05 -05:00
|
|
|
" Default mapping
|
2012-05-21 22:49:43 -04:00
|
|
|
if !hasmapto('<Plug>IndentGuidesToggle', 'n') && maparg('<Leader>ig', 'n') == ''
|
2013-06-26 02:28:01 -04:00
|
|
|
\ && g:indent_guides_default_mapping != 0
|
2012-05-21 18:52:46 -04:00
|
|
|
nmap <silent><unique> <Leader>ig <Plug>IndentGuidesToggle
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Plug mappings
|
|
|
|
nnoremap <unique><script> <Plug>IndentGuidesToggle :IndentGuidesToggle<CR>
|
|
|
|
nnoremap <unique><script> <Plug>IndentGuidesEnable :IndentGuidesEnable<CR>
|
|
|
|
nnoremap <unique><script> <Plug>IndentGuidesDisable :IndentGuidesDisable<CR>
|
2010-12-07 04:41:05 -05:00
|
|
|
|
2010-12-09 07:45:09 -05:00
|
|
|
" Auto commands
|
|
|
|
augroup indent_guides
|
|
|
|
autocmd!
|
2011-01-24 05:45:18 -05:00
|
|
|
|
|
|
|
if g:indent_guides_enable_on_vim_startup
|
|
|
|
autocmd VimEnter * :IndentGuidesEnable
|
|
|
|
endif
|
|
|
|
|
2013-03-06 06:57:33 -05:00
|
|
|
autocmd BufEnter,WinEnter,FileType * call indent_guides#process_autocmds()
|
2013-03-03 07:57:06 -05:00
|
|
|
|
|
|
|
" Trigger BufEnter and process modelines.
|
|
|
|
autocmd ColorScheme * doautocmd indent_guides BufEnter
|
2010-12-09 07:45:09 -05:00
|
|
|
augroup END
|