Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. " Statusline
  2.  
  3. function NormalHighlight()
  4. hi StatusMode ctermbg=148 ctermfg=22 term=bold cterm=bold
  5. hi StatusLeft ctermbg=240 ctermfg=231 term=none cterm=none
  6. hi StatusMiddle ctermbg=236 ctermfg=247 term=none cterm=none
  7. hi StatusRight1 ctermbg=252 ctermfg=241 term=none cterm=none
  8. hi StatusRight2 ctermbg=240 ctermfg=250 term=none cterm=none
  9. endfunction
  10. function InsertHighlight()
  11. hi StatusMode ctermbg=231 ctermfg=23 term=bold cterm=bold
  12. hi StatusLeft ctermbg=31 ctermfg=231 term=none cterm=none
  13. hi StatusMiddle ctermbg=24 ctermfg=117 term=none cterm=none
  14. hi StatusRight1 ctermbg=117 ctermfg=23 term=none cterm=none
  15. hi StatusRight2 ctermbg=31 ctermfg=117 term=none cterm=none
  16. endfunction
  17. function VisualHighlight()
  18. hi StatusMode ctermbg=208 ctermfg=88 term=bold cterm=bold
  19. hi StatusLeft ctermbg=240 ctermfg=231 term=none cterm=none
  20. hi StatusMiddle ctermbg=236 ctermfg=247 term=none cterm=none
  21. hi StatusRight1 ctermbg=252 ctermfg=241 term=none cterm=none
  22. hi StatusRight2 ctermbg=240 ctermfg=250 term=none cterm=none
  23. endfunction
  24. function ReplaceHighlight()
  25. hi StatusMode ctermbg=160 ctermfg=231 term=bold cterm=bold
  26. hi StatusLeft ctermbg=240 ctermfg=231 term=none cterm=none
  27. hi StatusMiddle ctermbg=236 ctermfg=247 term=none cterm=none
  28. hi StatusRight1 ctermbg=252 ctermfg=241 term=none cterm=none
  29. hi StatusRight2 ctermbg=240 ctermfg=250 term=none cterm=none
  30. endfunction
  31. hi StatusWarning ctermbg=136 ctermfg=235 term=none cterm=none
  32. hi InactiveStatusLeft ctermbg=235 ctermfg=240 term=none cterm=none
  33. hi InactiveStatusMiddle ctermbg=233 ctermfg=240 term=none cterm=none
  34. hi InactiveStatusRight1 ctermbg=241 ctermfg=235 term=none cterm=none
  35. hi InactiveStatusRight2 ctermbg=235 ctermfg=240 term=none cterm=none
  36.  
  37. function HighlightStatusline(mode)
  38. if a:mode == 'n'
  39. call NormalHighlight()
  40. elseif a:mode == 'i'
  41. call InsertHighlight()
  42. elseif a:mode == 'R'
  43. call ReplaceHighlight()
  44. elseif a:mode == 'v' || a:mode == 'V' || a:mode == ''
  45. call VisualHighlight()
  46. endif
  47. return ""
  48. endfunction
  49.  
  50. call NormalHighlight()
  51.  
  52. function StatusMode()
  53. return mode() == 'n' ? 'NORMAL' :
  54. \ mode() == 'i' ? 'INSERT' :
  55. \ mode() == 'R' ? 'REPLACE' :
  56. \ mode() == 'v' ? 'VISUAL' :
  57. \ mode() == 'V' ? 'V-LINE' :
  58. \ mode() == '' ? 'V-BLOCK' :
  59. \ mode()
  60. endfunction
  61.  
  62. function StatusGit()
  63. let symbols = ['+', '~', '-']
  64. let hunks = GitGutterGetHunkSummary()
  65. let ret = []
  66. for i in [0, 1, 2]
  67. if hunks[i] > 0
  68. call add(ret, symbols[i] . hunks[i])
  69. endif
  70. endfor
  71. let git = join(ret, ' ') . ' ⎇ ' . fugitive#head()
  72. return fugitive#head() != '' && winwidth('.') > 70 ? git : ''
  73. endfunction
  74.  
  75. function ActiveStatusline()
  76. return expand('%:t') == 'ControlP' ? '%#StatusLeft# '.g:StatusCtrlP_prev.' %#StatusMode#'.g:StatusCtrlP_item.' %#StatusLeft# '.g:StatusCtrlP_next.' %#StatusMiddle# regex: '.g:StatusCtrlP_regex :
  77. \ expand('%:t') == '__Gundo__' ? '%#StatusMode# Gundo %#StatusMiddle#' :
  78. \ expand('%:t') == '__Gundo_Preview__' ? '%#StatusMode# Preview %#StatusMiddle#' :
  79. \ expand('%:t') == '[calendar]' ? '%#StatusMode# Calendar %#StatusMiddle#' :
  80. \ '%#StatusMode# %{StatusMode()} '
  81. \ .'%#StatusLeft# %w%q%h%r%<%{substitute(fnamemodify(expand(''%''), '':~:.''), ''/'', '' / '', ''g'')}%m '
  82. \ .'%#StatusMiddle# %{StatusGit()}'
  83. \ .'%='
  84. \ .'%{&filetype} | %{&fileencoding} | %{&fileformat} '
  85. \ .'%#StatusRight2# %p%% '
  86. \ .'%#StatusRight1# %l:%c '
  87. \ .'%{HighlightStatusline(mode())}'
  88. \ .'%#StatusWarning#%{substitute(SyntasticStatuslineFlag(), ''[\[\]]'', '' '', ''g'')}'
  89. endfunction
  90.  
  91. function InactiveStatusline(name)
  92. let tail=fnamemodify(a:name, ':t')
  93. return tail == '__Gundo__' ? '%#InactiveStatusLeft# Gundo ' :
  94. \ tail == '__Gundo_Preview__' ? '%#InactiveStatusLeft# Preview ' :
  95. \ tail == '[calendar]' ? '%#InactiveStatusLeft# Calendar ' :
  96. \ '%#StatusLeft# %w%q%h%r%<%{substitute(fnamemodify(expand(''%''), '':~:.''), ''/'', '' / '', ''g'')}%m '
  97. \ .'%#InactiveStatusMiddle#'
  98. \ .'%='
  99. \ .'%#InactiveStatusRight2# %p%% '
  100. \ .'%#InactiveStatusRight1# %l:%c '
  101. endfunction
  102.  
  103. let g:ctrlp_status_func = {
  104. \ 'main': 'CtrlPStatusFunc_1',
  105. \ 'prog': 'CtrlPStatusFunc_2',
  106. \ }
  107.  
  108. function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked)
  109. let g:StatusCtrlP_regex = a:regex
  110. let g:StatusCtrlP_prev = a:prev
  111. let g:StatusCtrlP_item = a:item
  112. let g:StatusCtrlP_next = a:next
  113. return ActiveStatusline()
  114. endfunction
  115.  
  116. function! CtrlPStatusFunc_2(str)
  117. return InactiveStatusline()
  118. endfunction
  119.  
  120. function UpdateStatusline()
  121. let w = winnr()
  122. for n in range(1, winnr('$'))
  123. let f = getwinvar(n, 'netrw_prvfile')
  124. let s = winnr('$') == 1 ? [ActiveStatusline()] : [ActiveStatusline(), InactiveStatusline(f)]
  125. call setwinvar(n, '&statusline', s[n!=w])
  126. call setwinvar(n, 'lightline', n!=w)
  127. endfor
  128. endfunction
  129.  
  130. autocmd WinEnter,BufWinEnter * call UpdateStatusline()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement