Handle uncluttered buffers.
authorIain Patterson <me@iain.cx>
Fri, 26 Jun 2009 16:58:37 +0000 (17:58 +0100)
committerIain Patterson <me@iain.cx>
Wed, 8 Jul 2009 15:29:06 +0000 (16:29 +0100)
Don't set signs and numbers if Uncluttered_Buffer() returns true.
A buffer is uncluttered if the uncluttered_buffer variable is true.
A buffer is uncluttered if buftype is non-null.
A buffer is uncluttered if its filetype is svn, perforce or gitcommit.

.vimrc

diff --git a/.vimrc b/.vimrc
index 9cc96fd..3f4fd1d 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -366,6 +366,34 @@ map Q <NOP>
 " Vim tip 99: What's the highlighting group under the cursor?
 call Mapping("h", ":echo \"hi<\" . synIDattr(synID(line(\".\"),col(\".\"),1),\"name\") . '> trans<' . synIDattr(synID(line(\".\"),col(\".\"),0),\"name\") . \"> lo<\" . synIDattr(synIDtrans(synID(line(\".\"),col(\".\"),1)),\"name\") . \">\"<CR>")
 
 " Vim tip 99: What's the highlighting group under the cursor?
 call Mapping("h", ":echo \"hi<\" . synIDattr(synID(line(\".\"),col(\".\"),1),\"name\") . '> trans<' . synIDattr(synID(line(\".\"),col(\".\"),0),\"name\") . \"> lo<\" . synIDattr(synIDtrans(synID(line(\".\"),col(\".\"),1)),\"name\") . \">\"<CR>")
 
+fun! Uncluttered_Buffer()
+  if exists("uncluttered_buffer")
+    if uncluttered_buffer == 1
+      return 1
+    endif
+  endif
+
+  if version >= "600"
+    if &buftype != ''
+      return 1
+    endif
+  endif
+
+  if &ft == 'perforce'
+    return 1
+  endif
+
+  if &ft == 'svn'
+    return 1
+  endif
+
+  if &ft == 'gitcommit'
+    return 1
+  endif
+
+  return 0
+endfun
+
 fun! Startup_Resize()
   let l:columns = 0
 
 fun! Startup_Resize()
   let l:columns = 0
 
@@ -393,7 +421,7 @@ fun! Startup_Resize()
 endfun
 
 " Show numbers by default.
 endfun
 
 " Show numbers by default.
-au Display VimEnter * call Number(0)
+au Display VimEnter * if ! Uncluttered_Buffer() | call Number(0) | endif
 endif
 
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 endif
 
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -529,7 +557,7 @@ fun! <SID>Place_Sign(number, line, old, name)
 endfun
 
 fun! <SID>Highlight_Signs(...)
 endfun
 
 fun! <SID>Highlight_Signs(...)
-  if ! has("signs") || ! g:marksigns
+  if ! has("signs") || ! g:marksigns || Uncluttered_Buffer()
     return
   endif
 
     return
   endif