From 997bede1b54a523473ae653b9eae17071bd4f6b5 Mon Sep 17 00:00:00 2001 From: Nate Kane Date: Wed, 6 Mar 2013 21:57:33 +1000 Subject: [PATCH] Add option g:indent_guides_exclude_filetypes. For specifying a list of filetypes to disable the plugin for. Closes #20 and #26. --- autoload/indent_guides.vim | 17 +++++++++++++++++ doc/indent_guides.txt | 11 +++++++++++ plugin/indent_guides.vim | 6 +++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/autoload/indent_guides.vim b/autoload/indent_guides.vim index cad7c92..6cb85a7 100644 --- a/autoload/indent_guides.vim +++ b/autoload/indent_guides.vim @@ -33,6 +33,11 @@ endfunction function! indent_guides#enable() let g:indent_guides_autocmds_enabled = 1 + if indent_guides#exclude_filetype() + call indent_guides#clear_matches() + return + end + call indent_guides#init_script_vars() call indent_guides#highlight_colors() call indent_guides#clear_matches() @@ -261,3 +266,15 @@ function! indent_guides#indent_highlight_pattern(indent_pattern, column_start, i let l:pattern .= '\ze' return l:pattern endfunction + +" +" Detect if any of the buffer filetypes should be excluded. +" +function! indent_guides#exclude_filetype() + for ft in split(&ft, ',') + if index(g:indent_guides_exclude_filetypes, ft) > -1 + return 1 + end + endfor + return 0 +endfunction diff --git a/doc/indent_guides.txt b/doc/indent_guides.txt index 9a208be..adc9b14 100644 --- a/doc/indent_guides.txt +++ b/doc/indent_guides.txt @@ -150,6 +150,15 @@ Default: 0. Values: 0 or 1. let g:indent_guides_enable_on_vim_startup = 0 < +------------------------------------------------------------------------------ + *'indent_guides_exclude_filetypes'* +Use this option to specify a list of filetypes to disable the plugin for. + +Default: ['help']. Values: list of strings. +> + let g:indent_guides_exclude_filetypes = ['help', 'nerdtree'] +< + ============================================================================== 4. MAPPINGS *indent-guides-mappings* @@ -228,6 +237,8 @@ Bug reports, feedback, suggestions etc are welcomed. 1.7 (pending release)~ * Added way to override the default mapping (thanks xuhdev). + * Added option g:|indent_guides_exclude_filetypes| to specify a list of + filetypes to disable the plugin for. 1.6~ * Added option g:|indent_guides_space_guides| to control whether spaces are diff --git a/plugin/indent_guides.vim b/plugin/indent_guides.vim index 99a96a8..8664add 100644 --- a/plugin/indent_guides.vim +++ b/plugin/indent_guides.vim @@ -54,6 +54,10 @@ 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 ) +if !exists('g:indent_guides_exclude_filetypes') + let g:indent_guides_exclude_filetypes = ['help'] +endif + " Default mapping if !hasmapto('IndentGuidesToggle', 'n') && maparg('ig', 'n') == '' nmap ig IndentGuidesToggle @@ -72,7 +76,7 @@ augroup indent_guides autocmd VimEnter * :IndentGuidesEnable endif - autocmd BufEnter,WinEnter * call indent_guides#process_autocmds() + autocmd BufEnter,WinEnter,FileType * call indent_guides#process_autocmds() " Trigger BufEnter and process modelines. autocmd ColorScheme * doautocmd indent_guides BufEnter