]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
vimrc: Display unexpected 'fileformat'/'fileencoding' in statusline.
authorSimon Ruderich <simon@ruderich.org>
Sun, 2 Dec 2012 21:37:21 +0000 (22:37 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sun, 2 Dec 2012 21:37:21 +0000 (22:37 +0100)
vimrc

diff --git a/vimrc b/vimrc
index 5993bff360d6dea7766e06e228b16d6e293da2d7..7cf73622c75318ddc72552589d4395aa5d1640f3 100644 (file)
--- a/vimrc
+++ b/vimrc
@@ -387,6 +387,22 @@ 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'
+            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 +420,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 +446,10 @@ if has('statusline')
     set statusline+=%m                " [+] if buffer was modified,
                                       " [-] if 'modifiable' is off
     set statusline+=%r                " [RO] if buffer is read only
+    set statusline+=%#Error#          " display warnings
+    set statusline+=%{SFF()}          "   - unexpected file format
+    set statusline+=%{SFE()}          "   - unexpected file encoding
+    set statusline+=%##               " continue with normal colors
 
     " on the right
     set statusline+=%=                " right align