Fixed Ignore syntax.
[profile.git] / .vimrc
diff --git a/.vimrc b/.vimrc
index 77a1d45..baddfed 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -58,6 +58,9 @@ se smartcase
 " Look for ctags in home directory first.
 se tags=~/.tags,./tags,tags
 
+" Don't timeout waiting to interpet, eg, <ESC>OA as an escape code.
+se ttimeoutlen=100
+
 " Use - and = to create underlines.
 map - yyp:s/./-/g<RETURN>:let @/=''<RETURN>:<RETURN>
 map = yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>
@@ -68,6 +71,11 @@ map = yyp:s/./=/g<RETURN>:let @/=''<RETURN>:<RETURN>
 if version >= "500"
 version 5.0
 
+" Tell Vim we use dark backgrounds in our terminals.
+if ! has("gui_running")
+  se bg=dark
+endif
+
 " Vim 5 hardcodes the size of numbers column to 8.
 let numberwidth=8
 
@@ -340,15 +348,7 @@ map Qq :call Cycle_Quickfix()<CR>:<CR>
 " updated as a side-effect.
 map Qs :filetype detect<CR>:<CR>
 
-endif
-
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" Handle options only available in Vim 7 and above.
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-if version >= "700"
-version 7.0
-
-" Change status bar colour when entering insert mode.
+" Change status bar colour when various things happen.
 fun! Highlight_StatusLine(flag)
   " Get current status.
   call Iain_Vars()
@@ -358,27 +358,51 @@ fun! Highlight_StatusLine(flag)
   let b:iainstatus = substitute(b:iainstatus, re, a:flag, "")
 
   " Default colour.
-  let colour = "darkblue"
+  let s:colour = "darkblue"
+  let s:termcolour = ""
+  let s:term88colour = "17"
+  let s:term256colour = "17"
   " Maybe override depending on status.
   if b:iainstatus =~# "H"
     if b:iainstatus =~# "I"
       " Held in insert mode.  Add extra highlight if we don't have focus.
       if b:iainstatus =~# "f"
-        let colour = "darkmagenta"
+        let s:colour = "darkmagenta"
       else
-        let colour = "darkred"
+        let s:colour = "darkred"
       endif
+      let s:term88colour = "32"
+      let s:term256colour = "88"
     endif
   else
     if b:iainstatus =~# "I"
       " Regular insert mode.
-      let colour = "darkred"
+      let s:colour = "darkred"
+      let s:term88colour = "32"
+      let s:term256colour = "88"
     endif
   endif
 
-  exec "highlight StatusLine guifg=white guibg=" . colour . " ctermbg=white ctermfg=" . colour
+  if &t_Co == 88
+    let s:termcolour = s:term88colour
+  elseif &t_Co == 256
+    let s:termcolour = s:term256colour
+  else
+    let s:termcolour = s:colour
+  endif
+
+  exec "highlight StatusLine guifg=white guibg=" . s:colour . " ctermbg=white ctermfg=" . s:termcolour
 endfun
 
+call Highlight_StatusLine("")
+endif
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 7 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "700"
+version 7.0
+
 au CursorHoldI * call Highlight_StatusLine("H")
 au CursorMovedI * call Highlight_StatusLine("h")
 au FocusGained * call Highlight_StatusLine("F")