Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 81 lines (67 sloc) 3.548 kB
6c683de @spicycode Cleanup statusbar.vim
authored
1 " StatusBar:
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
2
6c683de @spicycode Cleanup statusbar.vim
authored
3 " Always show status bar
4 set laststatus=2
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
5
6c683de @spicycode Cleanup statusbar.vim
authored
6 " Inspired by StatusLineHighlight by Ingo Karkat
7 function! s:StatusLine(new_stl, type, current)
8 let current = (a:current ? "" : "NC")
9 let type = a:type
10 let new_stl = a:new_stl
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
11
6c683de @spicycode Cleanup statusbar.vim
authored
12 " Prepare current buffer specific text
13 " Syntax: <CUR> ... </CUR>
14 let new_stl = substitute(new_stl, '<CUR>\(.\{-,}\)</CUR>', (a:current ? '\1' : ''), 'g')
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
15
6c683de @spicycode Cleanup statusbar.vim
authored
16 " Prepare statusline colors
17 " Syntax: #[ ... ]
18 let new_stl = substitute(new_stl, '#\[\(\w\+\)\]', '%#StatusLine'.type.'\1'.current.'#', 'g')
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
19
6c683de @spicycode Cleanup statusbar.vim
authored
20 " Prepare statusline arrows
21 " Syntax: [>] [>>] [<] [<<]
22 let new_stl = substitute(new_stl, '\[>\]', '/', 'g')
23 let new_stl = substitute(new_stl, '\[>>\]', '/ ', 'g')
24 let new_stl = substitute(new_stl, '\[<\]', '\', 'g')
25 let new_stl = substitute(new_stl, '\[<<\]', '\', 'g')
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
26
6c683de @spicycode Cleanup statusbar.vim
authored
27 if &l:statusline ==# new_stl
28 " Statusline already set, nothing to do
29 return
30 endif
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
31
6c683de @spicycode Cleanup statusbar.vim
authored
32 if empty(&l:statusline)
33 " No statusline is set, use my_stl
34 let &l:statusline = new_stl
35 else
36 " Check if a custom statusline is set
37 let plain_stl = substitute(&l:statusline, '%#StatusLine\w\+#', '', 'g')
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
38
6c683de @spicycode Cleanup statusbar.vim
authored
39 if &l:statusline ==# plain_stl
40 " A custom statusline is set, don't modify
41 return
42 endif
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
43
6c683de @spicycode Cleanup statusbar.vim
authored
44 " No custom statusline is set, use my_stl
45 let &l:statusline = new_stl
46 endif
47 endfunction
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
48
6c683de @spicycode Cleanup statusbar.vim
authored
49 " Default statusline
50 let g:default_stl = ""
51 let g:default_stl .= "<CUR>#[Mode] %{&paste ? 'PASTE [>] ' : ''}%{mode()} #[ModeS][>>]</CUR>"
52 let g:default_stl .= "#[Branch] %(%{substitute(fugitive#statusline(), 'GIT(\\([a-z0-9\\-_\\./:]\\+\\))', '\\1', 'gi')}#[BranchS] [>] %)" " Git branch
53 let g:default_stl .= "#[FileName]%t " " File name
54 let g:default_stl .= "<CUR>#[Error]%(%{substitute(SyntasticStatuslineFlag(), '\\[Syntax: line:\\(\\d\\+\\) \\((\\(\\d\\+\\))\\)\\?\\]', '[>][>][>] SYNTAX đ \\1 \\2 [>][>][>]', 'i')} %)</CUR>" " Syntastic error flag
55 let g:default_stl .= "#[ModFlag]%(%M %)" " Modified flag
56 let g:default_stl .= "#[BufFlag]%(%H%W %)" " HLP,PRV flags
57 let g:default_stl .= "#[FileNameS][>>]" " Separator
58 let g:default_stl .= "#[FunctionName] " " Padding/HL group
59 let g:default_stl .= "%<" " Truncate right
60 let g:default_stl .= "<CUR>%(%{cfi#format('%s', '')} %)</CUR>" " Function name
61 let g:default_stl .= "%= " " Right align
62 let g:default_stl .= "<CUR>#[FileFormat]%{&fileformat} </CUR>" " File format
63 let g:default_stl .= "<CUR>#[FileEncoding]%{(&fenc == '' ? &enc : &fenc)} </CUR>" " File encoding
64 let g:default_stl .= "<CUR>#[Separator][<] #[FileType]%{strlen(&ft) ? &ft : 'n/a'} </CUR>" " File type
65 let g:default_stl .= "#[LinePercentS][<<]#[LinePercent] %p%% " " Line/column/virtual column, Line percentage
66 let g:default_stl .= "#[LineNumberS][<<]#[LineNumber] %l#[LineColumn]:%c%V " " Line/column/virtual column, Line percentage
67 let g:default_stl .= "%{exists('g:synid') && g:synid ? '[<] '.synIDattr(synID(line('.'), col('.'), 1), 'name').' ' : ''}" " Current syntax group
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
68
6c683de @spicycode Cleanup statusbar.vim
authored
69 " Statusline highlighting
70 augroup StatusLineHighlight
71 autocmd!
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
72 au BufEnter,BufWinEnter,WinEnter,CmdwinEnter,CursorHold,BufWritePost,InsertLeave * call <SID>StatusLine((exists('b:stl') ? b:stl : g:default_stl), 'Normal', 1)
73 au BufLeave,BufWinLeave,WinLeave,CmdwinLeave * call <SID>StatusLine((exists('b:stl') ? b:stl : g:default_stl), 'Normal', 0)
74 au InsertEnter,CursorHoldI * call <SID>StatusLine((exists('b:stl') ? b:stl : g:default_stl), 'Insert', 1)
75 augroup END
76
7c926e6 @spicycode Statusbar cleanup to remove errant 112s
authored
77 "let &t_SI="]12;\#89b6e2\x7"
78 "et &t_EI="]12;\#dd4010\x7"
3fc4745 @spicycode CRAZY STATUS IN THE TERMINAL
authored
79
7c926e6 @spicycode Statusbar cleanup to remove errant 112s
authored
80 "u VimLeave * silent !echo -ne "]12;\#dd4010\x7"
Something went wrong with that request. Please try again.