init.vim 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
  2. " vim: et ts=2 sts=2 sw=2
  3. function! s:check_defined(variable, default)
  4. if !exists(a:variable)
  5. let {a:variable} = a:default
  6. endif
  7. endfunction
  8. let s:loaded = 0
  9. function! airline#init#bootstrap()
  10. if s:loaded
  11. return
  12. endif
  13. let s:loaded = 1
  14. let g:airline#init#bootstrapping = 1
  15. call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b0":">")
  16. call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b1":">")
  17. call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b2":"<")
  18. call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"\ue0b3":"<")
  19. call s:check_defined('g:airline_detect_modified', 1)
  20. call s:check_defined('g:airline_detect_paste', 1)
  21. call s:check_defined('g:airline_detect_crypt', 1)
  22. call s:check_defined('g:airline_detect_iminsert', 0)
  23. call s:check_defined('g:airline_inactive_collapse', 1)
  24. call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
  25. call s:check_defined('g:airline_exclude_filetypes', [])
  26. call s:check_defined('g:airline_exclude_preview', 0)
  27. call s:check_defined('g:airline_mode_map', {})
  28. call extend(g:airline_mode_map, {
  29. \ '__' : '------',
  30. \ 'n' : 'NORMAL',
  31. \ 'i' : 'INSERT',
  32. \ 'R' : 'REPLACE',
  33. \ 'v' : 'VISUAL',
  34. \ 'V' : 'V-LINE',
  35. \ 'c' : 'COMMAND',
  36. \ '' : 'V-BLOCK',
  37. \ 's' : 'SELECT',
  38. \ 'S' : 'S-LINE',
  39. \ '' : 'S-BLOCK',
  40. \ 't' : 'TERMINAL',
  41. \ }, 'keep')
  42. call s:check_defined('g:airline_theme_map', {})
  43. call extend(g:airline_theme_map, {
  44. \ 'Tomorrow.*': 'tomorrow',
  45. \ 'base16.*': 'base16',
  46. \ 'mo[l|n]okai': 'molokai',
  47. \ 'wombat.*': 'wombat',
  48. \ '.*zenburn.*': 'zenburn',
  49. \ '.*solarized.*': 'solarized',
  50. \ }, 'keep')
  51. call s:check_defined('g:airline_symbols', {})
  52. call extend(g:airline_symbols, {
  53. \ 'paste': get(g:, 'airline_paste_symbol', 'PASTE'),
  54. \ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a2" : 'RO'),
  55. \ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? "\u2739" : '!',
  56. \ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a1" : ':' ),
  57. \ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? "\ue0a0" : ''),
  58. \ 'modified': '+',
  59. \ 'space': ' ',
  60. \ 'crypt': get(g:, 'airline_crypt_symbol', nr2char(0x1F512)),
  61. \ }, 'keep')
  62. call airline#parts#define('mode', {
  63. \ 'function': 'airline#parts#mode',
  64. \ 'accent': 'bold',
  65. \ })
  66. call airline#parts#define_function('iminsert', 'airline#parts#iminsert')
  67. call airline#parts#define_function('paste', 'airline#parts#paste')
  68. call airline#parts#define_function('crypt', 'airline#parts#crypt')
  69. call airline#parts#define_function('filetype', 'airline#parts#filetype')
  70. call airline#parts#define('readonly', {
  71. \ 'function': 'airline#parts#readonly',
  72. \ 'accent': 'red',
  73. \ })
  74. call airline#parts#define_raw('file', '%f%m')
  75. call airline#parts#define_raw('linenr', '%{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#')
  76. call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
  77. call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'eclim', 'whitespace','windowswap'])
  78. call airline#parts#define_text('capslock', '')
  79. unlet g:airline#init#bootstrapping
  80. endfunction
  81. function! airline#init#sections()
  82. let spc = g:airline_symbols.space
  83. if !exists('g:airline_section_a')
  84. let g:airline_section_a = airline#section#create_left(['mode', 'crypt', 'paste', 'capslock', 'iminsert'])
  85. endif
  86. if !exists('g:airline_section_b')
  87. let g:airline_section_b = airline#section#create(['hunks', 'branch'])
  88. endif
  89. if !exists('g:airline_section_c')
  90. let g:airline_section_c = airline#section#create(['%<', 'file', spc, 'readonly'])
  91. endif
  92. if !exists('g:airline_section_gutter')
  93. let g:airline_section_gutter = airline#section#create(['%='])
  94. endif
  95. if !exists('g:airline_section_x')
  96. let g:airline_section_x = airline#section#create_right(['tagbar', 'filetype'])
  97. endif
  98. if !exists('g:airline_section_y')
  99. let g:airline_section_y = airline#section#create_right(['ffenc'])
  100. endif
  101. if !exists('g:airline_section_z')
  102. let g:airline_section_z = airline#section#create(['windowswap', '%3p%%'.spc, 'linenr', ':%3v '])
  103. endif
  104. if !exists('g:airline_section_warning')
  105. let g:airline_section_warning = airline#section#create(['syntastic', 'eclim', 'whitespace'])
  106. endif
  107. endfunction