]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - vimrc
vimrc: Fix compatibility with Vim 6.4 and later.
[config/dotfiles.git] / vimrc
diff --git a/vimrc b/vimrc
index 5993bff360d6dea7766e06e228b16d6e293da2d7..8a6e07f4dc7ecf25224bc5ea4533232b881ddc76 100644 (file)
--- a/vimrc
+++ b/vimrc
@@ -387,6 +387,23 @@ if has('statusline')
         endif
     endfunction
 
+    " Display unexpected 'fileformat' and 'fileencoding' settings.
+    function! s:StatuslineFileFormat()
+        if &fileformat != 'unix'
+            return '[' . &fileformat . ']'
+        else
+            return ''
+        endif
+    endfunction
+    function! s:StatuslineFileEncoding()
+        if &fileencoding != '' && &fileencoding != 'utf-8'
+                \ && &filetype != 'help'
+            return '[' . &fileencoding . ']'
+        else
+            return ''
+        endif
+    endfunction
+
     " Return current syntax group in brackets or nothing if there's none.
     function! s:StatuslineSyntaxGroup()
         let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name')
@@ -404,6 +421,12 @@ if has('statusline')
     function! SRF()
         return <SID>StatuslineRelativeFilename()
     endfunction
+    function! SFF()
+        return <SID>StatuslineFileFormat()
+    endfunction
+    function! SFE()
+        return <SID>StatuslineFileEncoding()
+    endfunction
     function! SSG()
         return <SID>StatuslineSyntaxGroup()
     endfunction
@@ -424,6 +447,12 @@ if has('statusline')
     set statusline+=%m                " [+] if buffer was modified,
                                       " [-] if 'modifiable' is off
     set statusline+=%r                " [RO] if buffer is read only
+    if v:version >= 700               " %#..# needs 7.0
+        set statusline+=%#Error#      " display warnings
+        set statusline+=%{SFF()}      "   - unexpected file format
+        set statusline+=%{SFE()}      "   - unexpected file encoding
+        set statusline+=%##           " continue with normal colors
+    endif
 
     " on the right
     set statusline+=%=                " right align