1
0
mirror of https://github.com/amix/vimrc synced 2025-07-01 20:55:00 +08:00

Updated plugins

This commit is contained in:
amix
2016-03-14 11:04:57 +01:00
parent 71fc570357
commit 20729bff94
56 changed files with 726 additions and 404 deletions

View File

@ -72,9 +72,10 @@ endfunction
function! airline#switch_matching_theme()
if exists('g:colors_name')
let existing = g:airline_theme
let theme = substitute(g:colors_name, '-', '_', 'g')
try
let palette = g:airline#themes#{g:colors_name}#palette
call airline#switch_theme(g:colors_name)
let palette = g:airline#themes#{theme}#palette
call airline#switch_theme(theme)
return 1
catch
for map in items(g:airline_theme_map)

View File

@ -210,6 +210,10 @@ function! airline#extensions#load()
call airline#extensions#whitespace#init(s:ext)
endif
if get(g:, 'airline#extensions#po#enabled', 1) && executable('msgfmt')
call airline#extensions#po#init(s:ext)
endif
if get(g:, 'airline#extensions#wordcount#enabled', 1)
call airline#extensions#wordcount#init(s:ext)
endif

View File

@ -154,7 +154,7 @@ function! airline#extensions#branch#head()
if exists("g:airline#extensions#branch#displayed_head_limit")
let w:displayed_head_limit = g:airline#extensions#branch#displayed_head_limit
if len(b:airline_head) > w:displayed_head_limit - 1
let b:airline_head = b:airline_head[0:w:displayed_head_limit - 1].'…'
let b:airline_head = b:airline_head[0:(w:displayed_head_limit - 1)].(&encoding ==? 'utf-8' ? '…' : '.')
endif
endif

View File

@ -0,0 +1,36 @@
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#extensions#po#apply(...)
if &ft ==# 'po'
call airline#extensions#prepend_to_section('z', '%{airline#extensions#po#stats()}')
autocmd airline BufWritePost * unlet! b:airline_po_stats
endif
endfunction
function! airline#extensions#po#stats()
if exists('b:airline_po_stats') && !empty(b:airline_po_stats)
return b:airline_po_stats
endif
let airline_po_stats = system('msgfmt --statistics -o /dev/null -- '. expand('%:p'))
if v:shell_error
return ''
endif
try
let b:airline_po_stats = '['. split(airline_po_stats, '\n')[0]. ']'
catch
let b:airline_po_stats = ''
endtry
if exists("g:airline#extensions#po#displayed_limit")
let w:displayed_po_limit = g:airline#extensions#po#displayed_limit
if len(b:airline_po_stats) > w:displayed_po_limit - 1
let b:airline_po_stats = b:airline_po_stats[0:(w:displayed_po_limit - 1)].(&encoding==?'utf-8' ? '…' : '.')
endif
endif
return b:airline_po_stats
endfunction
function! airline#extensions#po#init(ext)
call a:ext.add_statusline_func('airline#extensions#po#apply')
endfunction

View File

@ -5,6 +5,7 @@ let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default')
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let s:show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1)
let s:ignore_bufadd_pat = get(g:, 'airline#extensions#tabline#ignore_bufadd_pat', '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree')
let s:taboo = get(g:, 'airline#extensions#taboo#enabled', 1) && get(g:, 'loaded_taboo', 0)
if s:taboo
let g:taboo_tabline = 0
@ -41,27 +42,21 @@ function! s:toggle_on()
endfunction
function! s:update_tabline()
if get(g:, 'airline#extensions#tabline#disable_refresh', 0)
return
endif
let match = expand('<afile>')
if pumvisible()
return
elseif !get(g:, 'airline#extensions#tabline#enabled', 0)
return
" return, if buffer matches ignore pattern or is directory (netrw)
elseif empty(match)
elseif empty(match)
\ || match(match, s:ignore_bufadd_pat) > -1
\ || isdirectory(expand("<afile>"))
return
endif
if empty(mapcheck("<Plug>AirlineTablineRefresh", 'n'))
noremap <silent> <Plug>AirlineTablineRefresh :set mod!<cr>
endif
call feedkeys("\<Plug>AirlineTablineRefresh")
call feedkeys("\<Plug>AirlineTablineRefresh")
"call feedkeys(',,', 't')
"call feedkeys(':unmap ,,')
" force re-evaluation of tabline setting
" disable explicit redraw, may cause E315
"redraw
doautocmd User BufMRUChange
endfunction
function! airline#extensions#tabline#load_theme(palette)
@ -92,6 +87,7 @@ function! airline#extensions#tabline#load_theme(palette)
" Theme for tabs on the right
let l:tabsel_right = get(colors, 'airline_tabsel_right', a:palette.normal.airline_a)
let l:tab_right = get(colors, 'airline_tab_right', a:palette.inactive.airline_c)
let l:tabmod_right = get(colors, 'airline_tabmod_right', a:palette.insert.airline_a)
let l:tabhid_right = get(colors, 'airline_tabhid_right', a:palette.normal.airline_c)
if has_key(a:palette, 'normal_modified') && has_key(a:palette.normal_modified, 'airline_c')
@ -100,6 +96,7 @@ function! airline#extensions#tabline#load_theme(palette)
"Fall back to normal airline_c if modified airline_c isn't present
let l:tabmodu_right = get(colors, 'airline_tabmod_unsel_right', a:palette.normal.airline_c)
endif
call airline#highlighter#exec('airline_tab_right', l:tab_right)
call airline#highlighter#exec('airline_tabsel_right', l:tabsel_right)
call airline#highlighter#exec('airline_tabmod_right', l:tabmod_right)
call airline#highlighter#exec('airline_tabhid_right', l:tabhid_right)
@ -163,3 +160,23 @@ function! airline#extensions#tabline#new_builder()
return airline#builder#new(builder_context)
endfunction
function! airline#extensions#tabline#group_of_bufnr(tab_bufs, bufnr)
let cur = bufnr('%')
if cur == a:bufnr
if g:airline_detect_modified && getbufvar(a:bufnr, '&modified')
let group = 'airline_tabmod'
else
let group = 'airline_tabsel'
endif
else
if g:airline_detect_modified && getbufvar(a:bufnr, '&modified')
let group = 'airline_tabmod_unsel'
elseif index(a:tab_bufs, a:bufnr) > -1
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif
endif
return group
endfunction

View File

@ -5,6 +5,7 @@ scriptencoding utf-8
let s:buffer_idx_mode = get(g:, 'airline#extensions#tabline#buffer_idx_mode', 0)
let s:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
let s:buffers_label = get(g:, 'airline#extensions#tabline#buffers_label', 'buffers')
let s:spc = g:airline_symbols.space
let s:current_bufnr = -1
@ -64,23 +65,16 @@ function! airline#extensions#tabline#buffers#get()
continue
endif
if cur == nr
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod'
else
let group = 'airline_tabsel'
endif
let group = airline#extensions#tabline#group_of_bufnr(tab_bufs, nr)
if nr == cur
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
else
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod_unsel'
elseif index(tab_bufs, nr) > -1
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif
endif
" Neovim feature: Have clickable buffers
if has("tablineat")
call b.add_raw('%'.nr.'@airline#extensions#tabline#buffers#switchbuf@')
endif
if s:buffer_idx_mode
if len(s:number_map) > 0
call b.add_section(group, s:spc . get(s:number_map, l:index, '') . '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)' . s:spc)
@ -91,13 +85,16 @@ function! airline#extensions#tabline#buffers#get()
else
call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc)
endif
if has("tablineat")
call b.add_raw('%X')
endif
endfor
call b.add_section('airline_tabfill', '')
call b.split()
call b.add_section('airline_tabfill', '')
if s:show_tab_type
call b.add_section('airline_tabtype', ' buffers ')
call b.add_section_spaced('airline_tabtype', s:buffers_label)
endif
let s:current_bufnr = cur
@ -198,3 +195,11 @@ function s:map_keys()
noremap <silent> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
endif
endfunction
function airline#extensions#tabline#buffers#switchbuf(minwid, clicks, button, modifiers) abort
" Run the following code only on a single left mouse button click without modifiers pressed
" works only in recent NeoVim with has('tablineat')
if a:clicks == 1 && a:button is# 'l' && a:modifiers !~# '[^ ]'
sil execute 'buffer' a:minwid
endif
endfunction

View File

@ -7,6 +7,12 @@ let s:current_bufnr = -1
let s:current_tabnr = -1
let s:current_tabline = ''
let s:buffers_label = get(g:, 'airline#extensions#tabline#buffers_label', 'buffers')
let s:tabs_label = get(g:, 'airline#extensions#tabline#tabs_label', 'tabs')
let s:switch_buffers_and_tabs = get(g:, 'airline#extensions#tabline#switch_buffers_and_tabs', 0)
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let s:show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1)
function! airline#extensions#tabline#ctrlspace#off()
augroup airline_tabline_ctrlspace
autocmd!
@ -25,6 +31,62 @@ function! airline#extensions#tabline#ctrlspace#invalidate()
let s:current_tabnr = -1
endfunction
function! airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, pos)
if a:pos == 0
let pos_extension = ''
else
let pos_extension = '_right'
endif
let s:buffer_list = ctrlspace#api#BufferList(a:cur_tab)
for buffer in s:buffer_list
if a:cur_buf == buffer.index
if buffer.modified
let group = 'airline_tabmod'.pos_extension
else
let group = 'airline_tabsel'.pos_extension
endif
else
if buffer.modified
let group = 'airline_tabmod_unsel'.pos_extension
elseif buffer.visible
let group = 'airline_tab'.pos_extension
else
let group = 'airline_tabhid'.pos_extension
endif
endif
let buf_name = '%(%{airline#extensions#tabline#get_buffer_name('.buffer.index.')}%)'
call a:builder.add_section_spaced(group, buf_name)
endfor
endfunction
function! airline#extensions#tabline#ctrlspace#add_tab_section(builder, pos)
if a:pos == 0
let pos_extension = ''
else
let pos_extension = '_right'
endif
for tab in s:tab_list
if tab.current
if tab.modified
let group = 'airline_tabmod'.pos_extension
else
let group = 'airline_tabsel'.pos_extension
endif
else
if tab.modified
let group = 'airline_tabmod_unsel'.pos_extension
else
let group = 'airline_tabhid'.pos_extension
endif
endif
call a:builder.add_section_spaced(group, tab.title.ctrlspace#api#TabBuffersNumber(tab.index))
endfor
endfunction
function! airline#extensions#tabline#ctrlspace#get()
let cur_buf = bufnr('%')
@ -39,59 +101,44 @@ function! airline#extensions#tabline#ctrlspace#get()
return s:current_tabline
endif
let b = airline#extensions#tabline#new_builder()
let builder = airline#extensions#tabline#new_builder()
call b.add_section_spaced('airline_tabtype', 'buffers')
let s:buffer_list = ctrlspace#api#BufferList(cur_tab)
for buffer in s:buffer_list
if cur_buf == buffer.index
if buffer.modified
let group = 'airline_tabmod'
else
let group = 'airline_tabsel'
endif
else
if buffer.modified
let group = 'airline_tabmod_unsel'
elseif buffer.visible
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif
endif
let buf_name = '%(%{airline#extensions#tabline#get_buffer_name('.buffer.index.')}%)'
call b.add_section_spaced(group, buf_name)
endfor
call b.add_section('airline_tabfill', '')
call b.split()
call b.add_section('airline_tabfill', '')
for tab in s:tab_list
if tab.current
if tab.modified
let group = 'airline_tabmod_right'
else
let group = 'airline_tabsel_right'
endif
" Add left tabline content
if s:show_buffers == 0
call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 0)
elseif s:show_tabs == 0
call airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0)
else
if s:switch_buffers_and_tabs == 0
call builder.add_section_spaced('airline_tabtype', s:buffers_label)
call airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0)
else
if tab.modified
let group = 'airline_tabmod_unsel_right'
else
let group = 'airline_tabhid_right'
endif
call builder.add_section_spaced('airline_tabtype', s:tabs_label)
call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 0)
endif
endif
call b.add_section_spaced(group, tab.title.ctrlspace#api#TabBuffersNumber(tab.index))
endfor
call builder.add_section('airline_tabfill', '')
call builder.split()
call builder.add_section('airline_tabfill', '')
call b.add_section_spaced('airline_tabtype', 'tabs')
" Add right tabline content
if s:show_buffers == 0
call builder.add_section_spaced('airline_tabtype', s:tabs_label)
elseif s:show_tabs == 0
call builder.add_section_spaced('airline_tabtype', s:buffers_label)
else
if s:switch_buffers_and_tabs == 0
call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 1)
call builder.add_section_spaced('airline_tabtype', s:tabs_label)
else
call airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 1)
call builder.add_section_spaced('airline_tabtype', s:buffers_label)
endif
endif
let s:current_bufnr = cur_buf
let s:current_tabnr = cur_tab
let s:current_tabline = b.build()
let s:current_tabline = builder.build()
return s:current_tabline
endfunction

View File

@ -1,11 +1,14 @@
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:show_tab_nr = get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0)
let s:show_close_button = get(g:, 'airline#extensions#tabline#show_close_button', 1)
let s:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
let s:show_tab_nr = get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0)
let s:close_symbol = get(g:, 'airline#extensions#tabline#close_symbol', 'X')
let s:tabs_label = get(g:, 'airline#extensions#tabline#tabs_label', 'tabs')
let s:show_splits = get(g:, 'airline#extensions#tabline#show_splits', 1)
let s:spc = g:airline_symbols.space
let s:current_bufnr = -1
let s:current_tabnr = -1
@ -39,19 +42,20 @@ function! airline#extensions#tabline#tabs#get()
endif
let b = airline#extensions#tabline#new_builder()
for i in range(1, tabpagenr('$'))
if i == curtab
let group = 'airline_tabsel'
let group = 'airline_tabsel_right'
if g:airline_detect_modified
for bi in tabpagebuflist(i)
if getbufvar(bi, '&modified')
let group = 'airline_tabmod'
let group = 'airline_tabmod_right'
endif
endfor
endif
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
let s:current_modified = (group == 'airline_tabmod_right') ? 1 : 0
else
let group = 'airline_tab'
let group = 'airline_tab_right'
endif
let val = '%('
if s:show_tab_nr
@ -66,14 +70,22 @@ function! airline#extensions#tabline#tabs#get()
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_tabfill', '')
if s:show_close_button
call b.add_section('airline_tab', ' %999X'.s:close_symbol.' ')
call b.add_section('airline_tab_right', ' %999X'.s:close_symbol.' ')
endif
if s:show_tab_type
call b.add_section('airline_tabtype', ' tabs ')
if s:show_splits == 1
let buffers = tabpagebuflist(curtab)
for nr in buffers
let group = airline#extensions#tabline#group_of_bufnr(buffers, nr)
call b.add_section_spaced(group, '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)')
endfor
elseif s:show_tab_type == 1
call b.add_section_spaced('airline_tabtype', s:tabs_label)
endif
let s:current_bufnr = curbuf

View File

@ -35,8 +35,14 @@ function! s:check_mixed_indent()
endfunction
function! s:check_mixed_indent_file()
if stridx(&ft, 'c') == 0 || stridx(&ft, 'cpp') == 0 || stridx(&ft, 'javascript') == 0
" for C/CPP only allow /** */ comment style with one space before the '*'
let head_spc = '\v(^ +\*@!)'
else
let head_spc = '\v(^ +)'
endif
let indent_tabs = search('\v(^\t+)', 'nw')
let indent_spc = search('\v(^ +)', 'nw')
let indent_spc = search(head_spc, 'nw')
if indent_tabs > 0 && indent_spc > 0
return printf("%d:%d", indent_tabs, indent_spc)
else

View File

@ -47,13 +47,12 @@ function! airline#init#bootstrap()
call s:check_defined('g:airline_theme_map', {})
call extend(g:airline_theme_map, {
\ 'Tomorrow.*': 'tomorrow',
\ 'base16.*': 'base16',
\ 'bubblegum': 'bubblegum',
\ '\CTomorrow': 'tomorrow',
\ 'base16': 'base16',
\ 'mo[l|n]okai': 'molokai',
\ 'wombat.*': 'wombat',
\ '.*zenburn.*': 'zenburn',
\ '.*solarized.*': 'solarized',
\ 'wombat': 'wombat',
\ 'zenburn': 'zenburn',
\ 'solarized': 'solarized',
\ }, 'keep')
call s:check_defined('g:airline_symbols', {})

View File

@ -70,7 +70,11 @@ function! airline#parts#iminsert()
endfunction
function! airline#parts#readonly()
return &readonly ? g:airline_symbols.readonly : ''
if &readonly && &modifiable && !filereadable(bufname('%'))
return '[noperm]'
else
return &readonly ? g:airline_symbols.readonly : ''
endif
endfunction
function! airline#parts#filetype()