mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 23:13:35 +08:00 
			
		
		
		
	Updated all the plugins. Removed powerline. Added vim-airline (replacement for powerline). Added vim-fugitive.
This commit is contained in:
		| @ -0,0 +1,76 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| let s:has_fugitive = exists('*fugitive#head') | ||||
| let s:has_fugitive_detect = exists('*fugitive#detect') | ||||
| let s:has_lawrencium = exists('*lawrencium#statusline') | ||||
| let s:has_vcscommand = get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine') | ||||
|  | ||||
| if !s:has_fugitive && !s:has_lawrencium && !s:has_vcscommand | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| let s:empty_message = get(g:, 'airline#extensions#branch#empty_message', | ||||
|       \ get(g:, 'airline_branch_empty_message', '')) | ||||
| let s:symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch) | ||||
|  | ||||
| function! airline#extensions#branch#get_head() | ||||
|   let head = '' | ||||
|  | ||||
|   if s:has_fugitive && !exists('b:mercurial_dir') | ||||
|     let head = fugitive#head() | ||||
|  | ||||
|     if empty(head) && s:has_fugitive_detect && !exists('b:git_dir') | ||||
|       call fugitive#detect(getcwd()) | ||||
|       let head = fugitive#head() | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   if empty(head) | ||||
|     if s:has_lawrencium | ||||
|       let head = lawrencium#statusline() | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   if empty(head) | ||||
|     if s:has_vcscommand | ||||
|       call VCSCommandEnableBufferSetup() | ||||
|       if exists('b:VCSCommandBufferInfo') | ||||
|         let head = get(b:VCSCommandBufferInfo, 0, '') | ||||
|       endif | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   return empty(head) || !s:check_in_path() | ||||
|         \ ? s:empty_message | ||||
|         \ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.(g:airline_symbols.space), head) | ||||
| endfunction | ||||
|  | ||||
| function! s:check_in_path() | ||||
|   if !exists('b:airline_branch_path') | ||||
|     let root = get(b:, 'git_dir', get(b:, 'mercurial_dir', '')) | ||||
|     let bufferpath = resolve(fnamemodify(expand('%'), ':p:h')) | ||||
|  | ||||
|     if !filereadable(root) "not a file | ||||
|       " if .git is a directory, it's the old submodule format | ||||
|       if match(root, '\.git$') >= 0 | ||||
|         let root = expand(fnamemodify(root, ':h')) | ||||
|       else | ||||
|         " else it's the newer format, and we need to guesstimate | ||||
|         let pattern = '\.git\(\\\|\/\)modules\(\\\|\/\)' | ||||
|         if match(root, pattern) >= 0 | ||||
|           let root = substitute(root, pattern, '', '') | ||||
|         endif | ||||
|     endif | ||||
|  | ||||
|     let b:airline_file_in_root = stridx(bufferpath, root) > -1 | ||||
|   endif | ||||
|   return b:airline_file_in_root | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#branch#init(ext) | ||||
|   call airline#parts#define_function('branch', 'airline#extensions#branch#get_head') | ||||
|  | ||||
|   autocmd BufReadPost * unlet! b:airline_file_in_root | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,23 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !exists('*bufferline#get_status_string') | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| let s:overwrite = get(g:, 'airline#extensions#bufferline#overwrite_variables', 1) | ||||
|  | ||||
| function! airline#extensions#bufferline#init(ext) | ||||
|   if s:overwrite | ||||
|     highlight bufferline_selected gui=bold cterm=bold term=bold | ||||
|     highlight link bufferline_selected_inactive airline_c_inactive | ||||
|     let g:bufferline_inactive_highlight = 'airline_c' | ||||
|     let g:bufferline_active_highlight = 'bufferline_selected' | ||||
|     let g:bufferline_active_buffer_left = '' | ||||
|     let g:bufferline_active_buffer_right = '' | ||||
|     let g:bufferline_separator = g:airline_symbols.space | ||||
|   endif | ||||
|  | ||||
|   call airline#parts#define_raw('file', '%{bufferline#refresh_status()}'.bufferline#get_status_string()) | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,16 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !get(g:, 'command_t_loaded', 0) | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| function! airline#extensions#commandt#apply(...) | ||||
|   if bufname('%') ==# 'GoToFile' | ||||
|     call airline#extensions#apply_left_override('CommandT', '') | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#commandt#init(ext) | ||||
|   call a:ext.add_statusline_func('airline#extensions#commandt#apply') | ||||
| endfunction | ||||
| @ -0,0 +1,31 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !get(g:, 'loaded_csv', 0) && !exists(':Table') | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| let s:column_display = get(g:, 'airline#extensions#csv#column_display', 'Number') | ||||
|  | ||||
| function! airline#extensions#csv#get_column() | ||||
|   if exists('*CSV_WCol') | ||||
|     if s:column_display ==# 'Name' | ||||
|       return '['.CSV_WCol('Name').CSV_WCol().']' | ||||
|     else | ||||
|       return '['.CSV_WCol().']' | ||||
|     endif | ||||
|   endif | ||||
|   return '' | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#csv#apply(...) | ||||
|   if &ft ==# "csv" | ||||
|     call airline#extensions#prepend_to_section('gutter', | ||||
|           \ g:airline_left_alt_sep.' %{airline#extensions#csv#get_column()}') | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#csv#init(ext) | ||||
|   call a:ext.add_statusline_func('airline#extensions#csv#apply') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,77 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !get(g:, 'loaded_ctrlp', 0) | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| let s:color_template = get(g:, 'airline#extensions#ctrlp#color_template', 'insert') | ||||
|  | ||||
| function! airline#extensions#ctrlp#generate_color_map(dark, light, white) | ||||
|   return { | ||||
|         \ 'CtrlPdark'   : a:dark, | ||||
|         \ 'CtrlPlight'  : a:light, | ||||
|         \ 'CtrlPwhite'  : a:white, | ||||
|         \ 'CtrlParrow1' : [ a:light[1] , a:white[1] , a:light[3] , a:white[3] , ''     ] , | ||||
|         \ 'CtrlParrow2' : [ a:white[1] , a:light[1] , a:white[3] , a:light[3] , ''     ] , | ||||
|         \ 'CtrlParrow3' : [ a:light[1] , a:dark[1]  , a:light[3] , a:dark[3]  , ''     ] , | ||||
|         \ } | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#ctrlp#load_theme(palette) | ||||
|   if exists('a:palette.ctrlp') | ||||
|     let theme = a:palette.ctrlp | ||||
|   else | ||||
|     let s:color_template = has_key(a:palette, s:color_template) ? s:color_template : 'insert' | ||||
|     let theme = airline#extensions#ctrlp#generate_color_map( | ||||
|           \ a:palette[s:color_template]['airline_c'], | ||||
|           \ a:palette[s:color_template]['airline_b'], | ||||
|           \ a:palette[s:color_template]['airline_a']) | ||||
|   endif | ||||
|   for key in keys(theme) | ||||
|     call airline#highlighter#exec(key, theme[key]) | ||||
|   endfor | ||||
| endfunction | ||||
|  | ||||
| " Arguments: focus, byfname, regexp, prv, item, nxt, marked | ||||
| function! airline#extensions#ctrlp#ctrlp_airline(...) | ||||
|   let b = airline#builder#new({'active': 1}) | ||||
|   if a:3 | ||||
|     call b.add_section_spaced('CtrlPlight', 'regex') | ||||
|   endif | ||||
|   if get(g:, 'airline#extensions#ctrlp#show_adjacent_modes', 1) | ||||
|     call b.add_section_spaced('CtrlPlight', a:4) | ||||
|     call b.add_section_spaced('CtrlPwhite', a:5) | ||||
|     call b.add_section_spaced('CtrlPlight', a:6) | ||||
|   else | ||||
|     call b.add_section_spaced('CtrlPwhite', a:5) | ||||
|   endif | ||||
|   call b.add_section_spaced('CtrlPdark', a:7) | ||||
|   call b.split() | ||||
|   call b.add_raw('%#CtrlPdark#'.a:1.(g:airline_symbols.space)) | ||||
|   call b.add_section_spaced('CtrlPdark', a:2) | ||||
|   call b.add_section_spaced('CtrlPlight', '%{getcwd()}') | ||||
|   return b.build() | ||||
| endfunction | ||||
|  | ||||
| " Argument: len | ||||
| function! airline#extensions#ctrlp#ctrlp_airline_status(...) | ||||
|   let len = '%#CtrlPdark# '.a:1 | ||||
|   let dir = '%=%<%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*' | ||||
|   return len.dir | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#ctrlp#apply(...) | ||||
|   " disable statusline overwrite if ctrlp already did it | ||||
|   return match(&statusline, 'CtrlPwhite') >= 0 ? -1 : 0 | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#ctrlp#init(ext) | ||||
|   let g:ctrlp_status_func = { | ||||
|         \ 'main': 'airline#extensions#ctrlp#ctrlp_airline', | ||||
|         \ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status', | ||||
|         \ } | ||||
|   call a:ext.add_statusline_func('airline#extensions#ctrlp#apply') | ||||
|   call a:ext.add_theme_func('airline#extensions#ctrlp#load_theme') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,77 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| let s:section_truncate_width = get(g:, 'airline#extensions#default#section_truncate_width', { | ||||
|       \ 'b': 79, | ||||
|       \ 'x': 60, | ||||
|       \ 'y': 88, | ||||
|       \ 'z': 45, | ||||
|       \ }) | ||||
| let s:layout = get(g:, 'airline#extensions#default#layout', [ | ||||
|       \ [ 'a', 'b', 'c' ], | ||||
|       \ [ 'x', 'y', 'z', 'warning' ] | ||||
|       \ ]) | ||||
|  | ||||
| function! s:get_section(winnr, key, ...) | ||||
|   if has_key(s:section_truncate_width, a:key) | ||||
|     if winwidth(a:winnr) < s:section_truncate_width[a:key] | ||||
|       return '' | ||||
|     endif | ||||
|   endif | ||||
|   let spc = g:airline_symbols.space | ||||
|   let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) | ||||
|   let [prefix, suffix] = [get(a:000, 0, '%('.spc), get(a:000, 1, spc.'%)')] | ||||
|   return empty(text) ? '' : prefix.text.suffix | ||||
| endfunction | ||||
|  | ||||
| function! s:build_sections(builder, context, keys) | ||||
|   for key in a:keys | ||||
|     if key == 'warning' && !a:context.active | ||||
|       continue | ||||
|     endif | ||||
|     call s:add_section(a:builder, a:context, key) | ||||
|   endfor | ||||
| endfunction | ||||
|  | ||||
| if v:version >= 704 || (v:version >= 703 && has('patch81')) | ||||
|   function s:add_section(builder, context, key) | ||||
|     " i have no idea why the warning section needs special treatment, but it's | ||||
|     " needed to prevent separators from showing up | ||||
|     if a:key == 'warning' | ||||
|       call a:builder.add_raw('%(') | ||||
|     endif | ||||
|     call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key)) | ||||
|     if a:key == 'warning' | ||||
|       call a:builder.add_raw('%)') | ||||
|     endif | ||||
|   endfunction | ||||
| else | ||||
|   " older version don't like the use of %(%) | ||||
|   function s:add_section(builder, context, key) | ||||
|     if a:key == 'warning' | ||||
|       call a:builder.add_raw('%#airline_warning#'.s:get_section(a:context.winnr, a:key)) | ||||
|     else | ||||
|       call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key)) | ||||
|     endif | ||||
|   endfunction | ||||
| endif | ||||
|  | ||||
| function! airline#extensions#default#apply(builder, context) | ||||
|   let winnr = a:context.winnr | ||||
|   let active = a:context.active | ||||
|  | ||||
|   if airline#util#getwinvar(winnr, 'airline_render_left', active || (!active && !g:airline_inactive_collapse)) | ||||
|     call <sid>build_sections(a:builder, a:context, s:layout[0]) | ||||
|   else | ||||
|     call a:builder.add_section('airline_c'.(a:context.bufnr), ' %f%m ') | ||||
|   endif | ||||
|  | ||||
|   call a:builder.split(s:get_section(winnr, 'gutter', '', '')) | ||||
|  | ||||
|   if airline#util#getwinvar(winnr, 'airline_render_right', 1) | ||||
|     call <sid>build_sections(a:builder, a:context, s:layout[1]) | ||||
|   endif | ||||
|  | ||||
|   return 1 | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,35 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !exists(':ProjectCreate') | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| function! airline#extensions#eclim#creat_line(...) | ||||
|   if &filetype == "tree" | ||||
|     let builder = a:1 | ||||
|     call builder.add_section('airline_a', ' Project ') | ||||
|     call builder.add_section('airline_b', ' %f ') | ||||
|     call builder.add_section('airline_c', '') | ||||
|   return 1 | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#eclim#get_warnings() | ||||
|   let eclimList = eclim#display#signs#GetExisting() | ||||
|   if !empty(eclimList) | ||||
|     let errorsLine = eclimList[0]['line'] | ||||
|     let errorsNumber = len(eclimList) | ||||
|     let errors = "[Eclim: line:".string(errorsLine)." (".string(errorsNumber).")]" | ||||
|     if !exists(':SyntasticCheck') || SyntasticStatuslineFlag() == '' | ||||
|       return errors.(g:airline_symbols.space) | ||||
|     endif | ||||
|   endif | ||||
|   return '' | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#eclim#init(ext) | ||||
|   call airline#parts#define_function('eclim', 'airline#extensions#eclim#get_warnings') | ||||
|   call a:ext.add_statusline_func('airline#extensions#eclim#creat_line') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,54 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| " we don't actually want this loaded :P | ||||
| finish | ||||
|  | ||||
| " Due to some potential rendering issues, the use of the `space` variable is | ||||
| " recommended. | ||||
| let s:spc = g:airline_symbols.space | ||||
|  | ||||
| " Extension specific variables can be defined the usual fashion. | ||||
| if !exists('g:airline#extensions#example#number_of_cats') | ||||
|   let g:airline#extensions#example#number_of_cats = 42 | ||||
| endif | ||||
|  | ||||
| " First we define an init function that will be invoked from extensions.vim | ||||
| function! airline#extensions#example#init(ext) | ||||
|  | ||||
|   " Here we define a new part for the plugin.  This allows users to place this | ||||
|   " extension in arbitrary locations. | ||||
|   call airline#parts#define_raw('cats', '%{airline#extensions#example#get_cats()}') | ||||
|  | ||||
|   " Next up we add a funcref so that we can run some code prior to the | ||||
|   " statusline getting modifed. | ||||
|   call a:ext.add_statusline_func('airline#extensions#example#apply') | ||||
|  | ||||
|   " You can also add a funcref for inactive statuslines. | ||||
|   " call a:ext.add_inactive_statusline_func('airline#extensions#example#unapply') | ||||
| endfunction | ||||
|  | ||||
| " This function will be invoked just prior to the statusline getting modified. | ||||
| function! airline#extensions#example#apply(...) | ||||
|   " First we check for the filetype. | ||||
|   if &filetype == "nyancat" | ||||
|  | ||||
|     " Let's say we want to append to section_c, first we check if there's | ||||
|     " already a window-local override, and if not, create it off of the global | ||||
|     " section_c. | ||||
|     let w:airline_section_c = get(w:, 'airline_section_c', g:airline_section_c) | ||||
|  | ||||
|     " Then we just append this extenion to it, optionally using separators. | ||||
|     let w:airline_section_c .= s:spc.g:airline_left_alt_sep.s:spc.'%{airline#extensions#example#get_cats()}' | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| " Finally, this function will be invoked from the statusline. | ||||
| function! airline#extensions#example#get_cats() | ||||
|   let cats = '' | ||||
|   for i in range(1, g:airline#extensions#example#number_of_cats) | ||||
|     let cats .= ' (,,,)=(^.^)=(,,,) ' | ||||
|   endfor | ||||
|   return cats | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,63 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| let s:non_zero_only = get(g:, 'airline#extensions#hunks#non_zero_only', 0) | ||||
| let s:hunk_symbols = get(g:, 'airline#extensions#hunks#hunk_symbols', ['+', '~', '-']) | ||||
|  | ||||
| function! s:get_hunks_signify() | ||||
|   let hunks = sy#repo#get_stats() | ||||
|   if hunks[0] >= 0 | ||||
|     return hunks | ||||
|   endif | ||||
|   return [] | ||||
| endfunction | ||||
|  | ||||
| function! s:get_hunks_gitgutter() | ||||
|   if !get(g:, 'gitgutter_enabled', 0) | ||||
|     return '' | ||||
|   endif | ||||
|   return GitGutterGetHunkSummary() | ||||
| endfunction | ||||
|  | ||||
| function! s:get_hunks_empty() | ||||
|   return '' | ||||
| endfunction | ||||
|  | ||||
| let s:source_func = '' | ||||
| function! s:get_hunks() | ||||
|   if empty(s:source_func) | ||||
|     if get(g:, 'loaded_signify', 0) | ||||
|       let s:source_func = 's:get_hunks_signify' | ||||
|     elseif exists('*GitGutterGetHunkSummary') | ||||
|       let s:source_func = 's:get_hunks_gitgutter' | ||||
|     else | ||||
|       let s:source_func = 's:get_hunks_empty' | ||||
|     endif | ||||
|   endif | ||||
|   return {s:source_func}() | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#hunks#get_hunks() | ||||
|   if !get(w:, 'airline_active', 0) | ||||
|     return '' | ||||
|   endif | ||||
|   let hunks = s:get_hunks() | ||||
|   let string = '' | ||||
|   if !empty(hunks) | ||||
|     for i in [0, 1, 2] | ||||
|       if s:non_zero_only == 0 || hunks[i] > 0 | ||||
|         let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i]) | ||||
|       endif | ||||
|     endfor | ||||
|   endif | ||||
|   return string | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#hunks#init(ext) | ||||
|   call airline#parts#define_function('hunks', 'airline#extensions#hunks#get_hunks') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,37 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| let g:airline#extensions#quickfix#quickfix_text = 'Quickfix' | ||||
| let g:airline#extensions#quickfix#location_text = 'Location' | ||||
|  | ||||
| function! airline#extensions#quickfix#apply(...) | ||||
|   if &buftype == 'quickfix' | ||||
|     let w:airline_section_a = s:get_text() | ||||
|     let w:airline_section_b = '%{get(w:, "quickfix_title", "")}' | ||||
|     let w:airline_section_c = '' | ||||
|     let w:airline_section_x = '' | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#quickfix#init(ext) | ||||
|   call a:ext.add_statusline_func('airline#extensions#quickfix#apply') | ||||
| endfunction | ||||
|  | ||||
| function! s:get_text() | ||||
|   redir => buffers | ||||
|   silent ls | ||||
|   redir END | ||||
|  | ||||
|   let nr = bufnr('%') | ||||
|   for buf in split(buffers, '\n') | ||||
|     if match(buf, '\v^\s+'.nr) > -1 | ||||
|       if match(buf, '\[Quickfix List\]') > -1 | ||||
|         return g:airline#extensions#quickfix#quickfix_text | ||||
|       else | ||||
|         return g:airline#extensions#quickfix#location_text | ||||
|       endif | ||||
|     endif | ||||
|   endfor | ||||
|   return '' | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,19 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !exists(':SyntasticCheck') | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| function! airline#extensions#syntastic#get_warnings() | ||||
|   let errors = SyntasticStatuslineFlag() | ||||
|   if strlen(errors) > 0 | ||||
|     return errors.(g:airline_symbols.space) | ||||
|   endif | ||||
|   return '' | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#syntastic#init(ext) | ||||
|   call airline#parts#define_function('syntastic', 'airline#extensions#syntastic#get_warnings') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,243 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default') | ||||
| let s:excludes = get(g:, 'airline#extensions#tabline#excludes', []) | ||||
| let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0) | ||||
| let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1) | ||||
|  | ||||
| let s:builder_context = { | ||||
|       \ 'active'        : 1, | ||||
|       \ 'right_sep'     : get(g:, 'airline#extensions#tabline#right_sep'    , g:airline_right_sep), | ||||
|       \ 'right_alt_sep' : get(g:, 'airline#extensions#tabline#right_alt_sep', g:airline_right_alt_sep), | ||||
|       \ } | ||||
| if get(g:, 'airline_powerline_fonts', 0) | ||||
|   let s:builder_context.left_sep     = get(g:, 'airline#extensions#tabline#left_sep'     , "\ue0b0") | ||||
|   let s:builder_context.left_alt_sep = get(g:, 'airline#extensions#tabline#left_alt_sep' , "\ue0b1") | ||||
| else | ||||
|   let s:builder_context.left_sep     = get(g:, 'airline#extensions#tabline#left_sep'     , ' ') | ||||
|   let s:builder_context.left_alt_sep = get(g:, 'airline#extensions#tabline#left_alt_sep' , '|') | ||||
| endif | ||||
|  | ||||
| let s:buf_min_count = get(g:, 'airline#extensions#tabline#buffer_min_count', 0) | ||||
| let s:tab_min_count = get(g:, 'airline#extensions#tabline#tab_min_count', 0) | ||||
| let s:spc = g:airline_symbols.space | ||||
|  | ||||
| function! airline#extensions#tabline#init(ext) | ||||
|   if has('gui_running') | ||||
|     set guioptions-=e | ||||
|   endif | ||||
|  | ||||
|   autocmd User AirlineToggledOn call s:toggle_on() | ||||
|   autocmd User AirlineToggledOff call s:toggle_off() | ||||
|  | ||||
|   call s:toggle_on() | ||||
|   call a:ext.add_theme_func('airline#extensions#tabline#load_theme') | ||||
| endfunction | ||||
|  | ||||
| function! s:toggle_off() | ||||
|   if exists('s:original_tabline') | ||||
|     let &tabline = s:original_tabline | ||||
|     let &showtabline = s:original_showtabline | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! s:toggle_on() | ||||
|   let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ] | ||||
|  | ||||
|   set tabline=%!airline#extensions#tabline#get() | ||||
|   if s:buf_min_count <= 0 && s:tab_min_count <= 1 | ||||
|     set showtabline=2 | ||||
|   else | ||||
|     augroup airline_tabline | ||||
|       autocmd! | ||||
|       if s:show_buffers == 1 | ||||
|         autocmd CursorMoved * call <sid>on_cursormove(s:buf_min_count, len(s:get_buffer_list())) | ||||
|       else | ||||
|         autocmd TabEnter * call <sid>on_cursormove(s:tab_min_count, tabpagenr('$')) | ||||
|       endif | ||||
|     augroup END | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tabline#load_theme(palette) | ||||
|   let colors    = get(a:palette, 'tabline', {}) | ||||
|   let l:tab     = get(colors, 'airline_tab', a:palette.normal.airline_b) | ||||
|   let l:tabsel  = get(colors, 'airline_tabsel', a:palette.normal.airline_a) | ||||
|   let l:tabtype = get(colors, 'airline_tabtype', a:palette.visual.airline_a) | ||||
|   let l:tabfill = get(colors, 'airline_tabfill', a:palette.normal.airline_c) | ||||
|   let l:tabmod  = get(colors, 'airline_tabmod', a:palette.insert.airline_a) | ||||
|   let l:tabhid  = get(colors, 'airline_tabhid', a:palette.normal.airline_c) | ||||
|   call airline#highlighter#exec('airline_tab', l:tab) | ||||
|   call airline#highlighter#exec('airline_tabsel', l:tabsel) | ||||
|   call airline#highlighter#exec('airline_tabtype', l:tabtype) | ||||
|   call airline#highlighter#exec('airline_tabfill', l:tabfill) | ||||
|   call airline#highlighter#exec('airline_tabmod', l:tabmod) | ||||
|   call airline#highlighter#exec('airline_tabhid', l:tabhid) | ||||
| endfunction | ||||
|  | ||||
| function! s:on_cursormove(min_count, total_count) | ||||
|   if a:total_count >= a:min_count | ||||
|     if &showtabline != 2 | ||||
|       set showtabline=2 | ||||
|     endif | ||||
|   else | ||||
|     if &showtabline != 0 | ||||
|       set showtabline=0 | ||||
|     endif | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tabline#get() | ||||
|   if s:show_buffers && tabpagenr('$') == 1 | ||||
|     return s:get_buffers() | ||||
|   else | ||||
|     return s:get_tabs() | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tabline#title(n) | ||||
|   let buflist = tabpagebuflist(a:n) | ||||
|   let winnr = tabpagewinnr(a:n) | ||||
|   return airline#extensions#tabline#get_buffer_name(buflist[winnr - 1]) | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tabline#get_buffer_name(nr) | ||||
|   return airline#extensions#tabline#formatters#{s:formatter}(a:nr, get(s:, 'current_buffer_list', [])) | ||||
| endfunction | ||||
|  | ||||
| function! s:get_buffer_list() | ||||
|   let buffers = [] | ||||
|   let cur = bufnr('%') | ||||
|   for nr in range(1, bufnr('$')) | ||||
|     if buflisted(nr) && bufexists(nr) | ||||
|       for ex in s:excludes | ||||
|         if match(bufname(nr), ex) | ||||
|           continue | ||||
|         endif | ||||
|       endfor | ||||
|       if getbufvar(nr, 'current_syntax') == 'qf' | ||||
|         continue | ||||
|       endif | ||||
|       call add(buffers, nr) | ||||
|     endif | ||||
|   endfor | ||||
|  | ||||
|   let s:current_buffer_list = buffers | ||||
|   return buffers | ||||
| endfunction | ||||
|  | ||||
| function! s:get_visible_buffers() | ||||
|   let buffers = s:get_buffer_list() | ||||
|   let cur = bufnr('%') | ||||
|  | ||||
|   let total_width = 0 | ||||
|   let max_width = 0 | ||||
|  | ||||
|   for nr in buffers | ||||
|     let width = len(airline#extensions#tabline#get_buffer_name(nr)) + 4 | ||||
|     let total_width += width | ||||
|     let max_width = max([max_width, width]) | ||||
|   endfor | ||||
|  | ||||
|   " only show current and surrounding buffers if there are too many buffers | ||||
|   let position  = index(buffers, cur) | ||||
|   let vimwidth = &columns | ||||
|   if total_width > vimwidth && position > -1 | ||||
|     let buf_count = len(buffers) | ||||
|  | ||||
|     " determine how many buffers to show based on the longest buffer width, | ||||
|     " use one on the right side and put the rest on the left | ||||
|     let buf_max   = vimwidth / max_width | ||||
|     let buf_right = 1 | ||||
|     let buf_left  = max([0, buf_max - buf_right]) | ||||
|  | ||||
|     let start = max([0, position - buf_left]) | ||||
|     let end   = min([buf_count, position + buf_right]) | ||||
|  | ||||
|     " fill up available space on the right | ||||
|     if position < buf_left | ||||
|       let end += (buf_left - position) | ||||
|     endif | ||||
|  | ||||
|     " fill up available space on the left | ||||
|     if end > buf_count - 1 - buf_right | ||||
|       let start -= max([0, buf_right - (buf_count - 1 - position)]) | ||||
|     endif | ||||
|  | ||||
|     let buffers = eval('buffers[' . start . ':' . end . ']') | ||||
|  | ||||
|     if start > 0 | ||||
|       call insert(buffers, -1, 0) | ||||
|     endif | ||||
|  | ||||
|     if end < buf_count - 1 | ||||
|       call add(buffers, -1) | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   return buffers | ||||
| endfunction | ||||
|  | ||||
| function! s:get_buffers() | ||||
|   let b = airline#builder#new(s:builder_context) | ||||
|   let cur = bufnr('%') | ||||
|   let tab_bufs = tabpagebuflist(tabpagenr()) | ||||
|   for nr in s:get_visible_buffers() | ||||
|     if nr < 0 | ||||
|       call b.add_raw('%#airline_tabhid#...') | ||||
|       continue | ||||
|     endif | ||||
|     if cur == nr | ||||
|       if g:airline_detect_modified && getbufvar(nr, '&modified') | ||||
|         let group = 'airline_tabmod' | ||||
|       else | ||||
|         let group = 'airline_tabsel' | ||||
|       endif | ||||
|     else | ||||
|       if index(tab_bufs, nr) > -1 | ||||
|         let group = 'airline_tab' | ||||
|       else | ||||
|         let group = 'airline_tabhid' | ||||
|       endif | ||||
|     endif | ||||
|     call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc) | ||||
|   endfor | ||||
|  | ||||
|   call b.add_section('airline_tabfill', '') | ||||
|   call b.split() | ||||
|   call b.add_section('airline_tabtype', ' buffers ') | ||||
|   return b.build() | ||||
| endfunction | ||||
|  | ||||
| function! s:get_tabs() | ||||
|   let b = airline#builder#new(s:builder_context) | ||||
|   for i in range(1, tabpagenr('$')) | ||||
|     if i == tabpagenr() | ||||
|       let group = 'airline_tabsel' | ||||
|       if g:airline_detect_modified | ||||
|         for bi in tabpagebuflist(i) | ||||
|           if getbufvar(bi, '&modified') | ||||
|             let group = 'airline_tabmod' | ||||
|           endif | ||||
|         endfor | ||||
|       endif | ||||
|     else | ||||
|       let group = 'airline_tab' | ||||
|     endif | ||||
|     let val = '%(' | ||||
|     if s:tab_nr_type == 0 | ||||
|       let val .= ' %{len(tabpagebuflist('.i.'))}' | ||||
|     else | ||||
|       let val .= (g:airline_symbols.space).i | ||||
|     endif | ||||
|     call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)') | ||||
|   endfor | ||||
|   call b.add_raw('%T') | ||||
|   call b.add_section('airline_tabfill', '') | ||||
|   call b.split() | ||||
|   call b.add_section('airline_tab', ' %999XX ') | ||||
|   call b.add_section('airline_tabtype', ' tabs ') | ||||
|   return b.build() | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,60 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.') | ||||
| let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1) | ||||
| let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s: ') | ||||
| let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0) | ||||
| let s:buf_modified_symbol = g:airline_symbols.modified | ||||
|  | ||||
| function! airline#extensions#tabline#formatters#default(bufnr, buffers) | ||||
|   let _ = '' | ||||
|  | ||||
|   let name = bufname(a:bufnr) | ||||
|   if empty(name) | ||||
|     let _ .= '[No Name]' | ||||
|   else | ||||
|     if s:fnamecollapse | ||||
|       let _ .= substitute(fnamemodify(name, s:fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g') | ||||
|     else | ||||
|       let _ .= fnamemodify(name, s:fmod) | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   return s:wrap_name(a:bufnr, _) | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tabline#formatters#unique_tail(bufnr, buffers) | ||||
|   let duplicates = {} | ||||
|   let tails = {} | ||||
|   let map = {} | ||||
|   for nr in a:buffers | ||||
|     let name = bufname(nr) | ||||
|     if empty(name) | ||||
|       let map[nr] = '[No Name]' | ||||
|     else | ||||
|       let tail = fnamemodify(name, ':t') | ||||
|       if has_key(tails, tail) | ||||
|         let duplicates[nr] = nr | ||||
|       endif | ||||
|       let tails[tail] = 1 | ||||
|       let map[nr] = s:wrap_name(nr, tail) | ||||
|     endif | ||||
|   endfor | ||||
|  | ||||
|   for nr in values(duplicates) | ||||
|     let map[nr] = s:wrap_name(nr, fnamemodify(bufname(nr), ':p:.')) | ||||
|   endfor | ||||
|  | ||||
|   return map[a:bufnr] | ||||
| endfunction | ||||
|  | ||||
| function! s:wrap_name(bufnr, buffer_name) | ||||
|   let _ = s:buf_nr_show ? printf(s:buf_nr_format, a:bufnr) : '' | ||||
|   let _ .= a:buffer_name | ||||
|   if getbufvar(a:bufnr, '&modified') == 1 | ||||
|     let _ .= s:buf_modified_symbol | ||||
|   endif | ||||
|   return _ | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,39 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !exists(':TagbarToggle') | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| let s:flags = get(g:, 'airline#extensions#tagbar#flags', '') | ||||
| let s:spc = g:airline_symbols.space | ||||
|  | ||||
| " Arguments: current, sort, fname | ||||
| function! airline#extensions#tagbar#get_status(...) | ||||
|   let builder = airline#builder#new({ 'active': a:1 }) | ||||
|   call builder.add_section('airline_a', s:spc.'Tagbar'.s:spc) | ||||
|   call builder.add_section('airline_b', s:spc.a:2.s:spc) | ||||
|   call builder.add_section('airline_c', s:spc.a:3.s:spc) | ||||
|   return builder.build() | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tagbar#inactive_apply(...) | ||||
|   if getwinvar(a:2.winnr, '&filetype') == 'tagbar' | ||||
|     return -1 | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tagbar#currenttag() | ||||
|   if get(w:, 'airline_active', 0) | ||||
|     return tagbar#currenttag('%s', '', s:flags) | ||||
|   endif | ||||
|   return '' | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#tagbar#init(ext) | ||||
|   call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply') | ||||
|   let g:tagbar_status_func = 'airline#extensions#tagbar#get_status' | ||||
|  | ||||
|   call airline#parts#define_function('tagbar', 'airline#extensions#tagbar#currenttag') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,27 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !exists(':UndotreeToggle') | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| function! airline#extensions#undotree#apply(...) | ||||
|   if exists('t:undotree') | ||||
|     if &ft == 'undotree' | ||||
|       if exists('*t:undotree.GetStatusLine') | ||||
|         call airline#extensions#apply_left_override('undo', '%{t:undotree.GetStatusLine()}') | ||||
|       else | ||||
|         call airline#extensions#apply_left_override('undotree', '%f') | ||||
|       endif | ||||
|     endif | ||||
|  | ||||
|     if &ft == 'diff' && exists('*t:diffpanel.GetStatusLine') | ||||
|       call airline#extensions#apply_left_override('diff', '%{t:diffpanel.GetStatusLine()}') | ||||
|     endif | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#undotree#init(ext) | ||||
|   call a:ext.add_statusline_func('airline#extensions#undotree#apply') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,23 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !get(g:, 'loaded_unite', 0) | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| function! airline#extensions#unite#apply(...) | ||||
|   if &ft == 'unite' | ||||
|     call a:1.add_section('airline_a', ' Unite ') | ||||
|     call a:1.add_section('airline_b', ' %{get(unite#get_context(), "buffer_name", "")} ') | ||||
|     call a:1.add_section('airline_c', ' %{unite#get_status_string()} ') | ||||
|     call a:1.split() | ||||
|     call a:1.add_section('airline_y', ' %{get(unite#get_context(), "real_buffer_name", "")} ') | ||||
|     return 1 | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#unite#init(ext) | ||||
|   let g:unite_force_overwrite_statusline = 0 | ||||
|   call a:ext.add_statusline_func('airline#extensions#unite#apply') | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,20 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| if !get(g:, 'virtualenv_loaded', 0) | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| let s:spc = g:airline_symbols.space | ||||
|  | ||||
| function! airline#extensions#virtualenv#init(ext) | ||||
|   call a:ext.add_statusline_func('airline#extensions#virtualenv#apply') | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#virtualenv#apply(...) | ||||
|   if &filetype =~ "python" | ||||
|     call airline#extensions#append_to_section('x', | ||||
|           \ s:spc.g:airline_right_alt_sep.s:spc.'%{virtualenv#statusline()}') | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| @ -0,0 +1,78 @@ | ||||
| " MIT License. Copyright (c) 2013 Bailey Ling. | ||||
| " vim: et ts=2 sts=2 sw=2 | ||||
|  | ||||
| " http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html | ||||
|  | ||||
| " for backwards compatibility | ||||
| if exists('g:airline_detect_whitespace') | ||||
|   let s:show_message = g:airline_detect_whitespace == 1 | ||||
| else | ||||
|   let s:show_message = get(g:, 'airline#extensions#whitespace#show_message', 1) | ||||
| endif | ||||
|  | ||||
| let s:symbol = get(g:, 'airline#extensions#whitespace#symbol', g:airline_symbols.whitespace) | ||||
| let s:default_checks = ['indent', 'trailing'] | ||||
|  | ||||
| let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', 'trailing[%s]') | ||||
| let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', 'mixed-indent[%s]') | ||||
|  | ||||
| let s:enabled = 1 | ||||
|  | ||||
| function! airline#extensions#whitespace#check() | ||||
|   if &readonly || !&modifiable || !s:enabled | ||||
|     return '' | ||||
|   endif | ||||
|  | ||||
|   if !exists('b:airline_whitespace_check') | ||||
|     let b:airline_whitespace_check = '' | ||||
|     let checks = get(g:, 'airline#extensions#whitespace#checks', s:default_checks) | ||||
|  | ||||
|     let trailing = 0 | ||||
|     if index(checks, 'trailing') > -1 | ||||
|       let trailing = search(' $', 'nw') | ||||
|     endif | ||||
|  | ||||
|     let mixed = 0 | ||||
|     if index(checks, 'indent') > -1 | ||||
|       let indents = [search('^ \{2,}', 'nb'), search('^ \{2,}', 'n'), search('^\t', 'nb'), search('^\t', 'n')] | ||||
|       let mixed = indents[0] != 0 && indents[1] != 0 && indents[2] != 0 && indents[3] != 0 | ||||
|     endif | ||||
|  | ||||
|     if trailing != 0 || mixed | ||||
|       let b:airline_whitespace_check = s:symbol | ||||
|       if s:show_message | ||||
|         if trailing != 0 | ||||
|           let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:trailing_format, trailing) | ||||
|         endif | ||||
|         if mixed | ||||
|           let mixnr = indents[0] == indents[1] ? indents[0] : indents[2] | ||||
|           let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_format, mixnr) | ||||
|         endif | ||||
|       endif | ||||
|     endif | ||||
|   endif | ||||
|   return b:airline_whitespace_check | ||||
| endfunction! | ||||
|  | ||||
| function! airline#extensions#whitespace#toggle() | ||||
|   if s:enabled | ||||
|     autocmd! airline_whitespace CursorHold,BufWritePost | ||||
|     augroup! airline_whitespace | ||||
|     let s:enabled = 0 | ||||
|   else | ||||
|     call airline#extensions#whitespace#init() | ||||
|     let s:enabled = 1 | ||||
|   endif | ||||
|   echo 'Whitespace checking: '.(s:enabled ? 'Enabled' : 'Disabled') | ||||
| endfunction | ||||
|  | ||||
| function! airline#extensions#whitespace#init(...) | ||||
|   call airline#parts#define_function('whitespace', 'airline#extensions#whitespace#check') | ||||
|  | ||||
|   unlet! b:airline_whitespace_check | ||||
|   augroup airline_whitespace | ||||
|     autocmd! | ||||
|     autocmd CursorHold,BufWritePost * unlet! b:airline_whitespace_check | ||||
|   augroup END | ||||
| endfunction | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 amix
					amix