Skip to content
Newer
Older
100644 149 lines (112 sloc) 3.94 KB
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
1 " ============================================================================
2 " File: statline.vim
3 " Maintainer: Miller Medeiros <http://blog.millermedeiros.com/>
4 " Description: Add useful info to the statusline and basic error checking.
5 " Last Change: October 05, 2011
6 " License: This program is free software. It comes without any warranty,
7 " to the extent permitted by applicable law. You can redistribute
8 " it and/or modify it under the terms of the Do What The Fuck You
9 " Want To Public License, Version 2, as published by Sam Hocevar.
10 " See http://sam.zoy.org/wtfpl/COPYING for more details.
11 " ============================================================================
12
13
14
15 " ====== colors ======
16
17 " using link instead of named highlight group inside the statusline to make it
18 " easier to customize, reseting the User[n] highlight will remove the link.
19 " Another benefit is that colors will adapt to colorscheme.
20
21 "filename
dd95295 @millermedeiros use 'default' in ':hi-link' to make it easier to overwrite links insi…
millermedeiros authored Oct 6, 2011
22 hi default link User1 Identifier
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
23 " flags
dd95295 @millermedeiros use 'default' in ':hi-link' to make it easier to overwrite links insi…
millermedeiros authored Oct 6, 2011
24 hi default link User2 Statement
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
25 " errors
dd95295 @millermedeiros use 'default' in ':hi-link' to make it easier to overwrite links insi…
millermedeiros authored Oct 6, 2011
26 hi default link User3 Error
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
27 " fugitive
dd95295 @millermedeiros use 'default' in ':hi-link' to make it easier to overwrite links insi…
millermedeiros authored Oct 6, 2011
28 hi default link User4 Special
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
29
30
31
32 " ====== basic info ======
33
34
35 " buffer number (always shown)
36 set statusline=[%n]\ %<
37 " filename (tail)
38 set statusline+=%1*[%t]%*
39 " flags (h:help:[help], w:window:[Preview], m:modified:[+][-], r:readonly:[RO])
40 set statusline+=%2*%h%w%m%r%*
41 " filetype
42 set statusline+=\ %y
5484773 Optionally turn off the file format and encoding
Matthew Kitt authored Oct 16, 2011
43
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
44 " file format → file encoding
5484773 Optionally turn off the file format and encoding
Matthew Kitt authored Oct 17, 2011
45 if !exists('g:statline_show_encoding')
46 let g:statline_show_encoding = 1
47 endif
48 if g:statline_show_encoding
49 set statusline+=[%{&ff}→%{strlen(&fenc)?&fenc:'No\ Encoding'}]
50 endif
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
51
52 " separation between left/right aligned items
53 set statusline+=%=
54
1081e23 @millermedeiros improve README, delete images, remove trailing spaces.
millermedeiros authored Oct 6, 2011
55 " current line and column (-:left align, 14:minwid, l:line, L:nLines, c:column)
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
56 set statusline+=%-14(\ L%l/%L:C%c\ %)
57 " scroll percent
58 set statusline+=%P
59
60
59b1f3a Add optional status for displaying rvm version
Matthew Kitt authored Oct 16, 2011
61 " RVM
62 if !exists('g:statline_rvm')
63 let g:statline_rvm = 0
64 endif
65 if g:statline_rvm
66 set statusline+=%{rvm#statusline()}
67 endif
68
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
69
70 " Fugitive
71 if !exists('g:statline_fugitive')
72 let g:statline_fugitive = 0
73 endif
74 if g:statline_fugitive
75 set statusline+=%4*%{fugitive#statusline()}%*
76 endif
77
78
79 " Syntastic errors
80 if !exists('g:statline_syntastic')
81 let g:statline_syntastic = 1
82 endif
83 if g:statline_syntastic
84 set statusline+=\ %3*%{SyntasticStatuslineFlag()}%*
85 endif
86
87
88
89
90 " ====== custom errors ======
91
92
93 " these methods were based on factorylabs/vimfiles
94
95
96 " ---- mixed indenting ----
97
98 if !exists('g:statline_mixed_indent')
99 let g:statline_mixed_indent = 1
100 endif
101
102 function! StatlineTabWarning()
103 if !exists("b:statline_indent_warning")
104 let tabs = search('^\t', 'nw') != 0
105 " ignore spaces just before JavaDoc style comments
106 let spaces = search('^ \(?<!*\)', 'nw') != 0
107 let mixed = search('^\( \+\t\|\t\+ \+\(?<!*\)\)', 'nw') != 0
108
109 if mixed
110 let b:statline_indent_warning = '[mixed-indenting]'
111 elseif (spaces && !&et) || (tabs && &et)
112 let b:statline_indent_warning = '[&et]'
113 else
114 let b:statline_indent_warning = ''
115 endif
116 endif
117 return b:statline_indent_warning
118 endfunction
119
120 if g:statline_mixed_indent
121 set statusline+=%3*%{StatlineTabWarning()}%*
1081e23 @millermedeiros improve README, delete images, remove trailing spaces.
millermedeiros authored Oct 6, 2011
122 " recalculate when idle and after writing
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
123 autocmd cursorhold,bufwritepost * unlet! b:statline_indent_warning
124 endif
125
126
127 " --- trailing white space ---
128
129 if !exists('g:statline_trailing_space')
130 let g:statline_trailing_space = 1
131 endif
132
133 function! StatlineTrailingSpaceWarning()
134 if !exists("b:statline_trailing_space_warning")
135 if search('\s\+$', 'nw') != 0
136 let b:statline_trailing_space_warning = '[\s]'
137 else
138 let b:statline_trailing_space_warning = ''
139 endif
140 endif
c42aa3f @millermedeiros fix typo error..
millermedeiros authored Oct 6, 2011
141 return b:statline_trailing_space_warning
7590989 @millermedeiros initial commit
millermedeiros authored Oct 6, 2011
142 endfunction
143
144 if g:statline_trailing_space
145 set statusline+=%3*%{StatlineTrailingSpaceWarning()}%*
146 " recalculate when idle, and after saving
147 autocmd cursorhold,bufwritepost * unlet! b:statline_trailing_space_warning
148 endif
Something went wrong with that request. Please try again.