Permalink
Browse files

Improved support for terminal vim

  • Loading branch information...
nathanaelkane committed Dec 20, 2010
1 parent 6d903df commit 14aae71298ce94f1a3759d9f4d5042f60a221c02
Showing with 22 additions and 15 deletions.
  1. +21 −14 autoload/indent_guides.vim
  2. +1 −1 plugin/indent_guides.vim
View
@@ -77,10 +77,6 @@ endfunction
" Automagically calculates and defines the indent highlight colors.
"
function! indent_guides#highlight_colors()
- " define default highlights
- exe 'hi IndentGuidesOdd guibg=lightgrey ctermbg=1'
- exe 'hi IndentGuidesEven guibg=darkgrey ctermbg=0'
-
if g:indent_guides_auto_colors
if has('gui_running')
call indent_guides#gui_highlight_colors()
@@ -95,28 +91,31 @@ endfunction
" terminal vim.
"
function! indent_guides#cterm_highlight_colors()
- let hi_search = indent_guides#capture_highlight('search')
- let pattern = "ctermbg=\\zs[0-9A-Za-z]\\+\\ze"
+ let hi_search = indent_guides#capture_highlight('Search')
+ let ctermfg_pattern = "ctermfg=\\zs[0-9A-Za-z]\\+\\ze"
+ let ctermbg_pattern = "ctermbg=\\zs[0-9A-Za-z]\\+\\ze"
+ let hi_search_ctermfg = ''
let hi_search_ctermbg = ''
- " capture the backgroud color from the search highlight
- if hi_search =~ pattern
- let hi_search_ctermbg = matchstr(hi_search, pattern)
+ " capture the foreground color from the search highlight
+ if hi_search =~ ctermfg_pattern
+ let hi_search_ctermfg = matchstr(hi_search, ctermfg_pattern)
+ exe 'hi IndentGuidesOdd ctermbg=' . hi_search_ctermfg
endif
- if hi_search_ctermbg =~ "[0-9A-Za-z]\\+"
- " define the new highlights
- exe 'hi IndentGuidesOdd ctermbg=none'
+ " capture the background color from the search highlight
+ if hi_search =~ ctermbg_pattern
+ let hi_search_ctermbg = matchstr(hi_search, ctermbg_pattern)
exe 'hi IndentGuidesEven ctermbg=' . hi_search_ctermbg
- end
+ endif
endfunction
"
" Automagically calculates and defines the indent highlight colors for gui
" vim.
"
function! indent_guides#gui_highlight_colors()
- let hi_normal = indent_guides#capture_highlight('normal')
+ let hi_normal = indent_guides#capture_highlight('Normal')
let hex_pattern = 'guibg=\zs'. g:indent_guides_hex_color_pattern . '\ze'
let name_pattern = "guibg='\\?\\zs[0-9A-Za-z ]\\+\\ze'\\?"
let hi_normal_guibg = ''
@@ -178,3 +177,11 @@ function! indent_guides#init_matches()
\ exists('w:indent_guides_matches') ? w:indent_guides_matches : []
endfunction
+"
+" Define default highlights.
+"
+function! indent_guides#define_default_highlights()
+ exe 'hi IndentGuidesOdd guibg=none ctermbg=none'
+ exe 'hi IndentGuidesEven guibg=none ctermbg=none'
+endfunction
+
View
@@ -4,8 +4,8 @@
if exists('g:loaded_indent_guides') || &cp
finish
endif
-
let g:loaded_indent_guides = 1
+call indent_guides#define_default_highlights()
function! s:IndentGuidesToggle()
call indent_guides#toggle()

0 comments on commit 14aae71

Please sign in to comment.