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

Updated plugins

This commit is contained in:
amix
2016-05-14 12:57:54 +01:00
parent 5f6aa8fe09
commit f343b66088
105 changed files with 2100 additions and 4902 deletions

View File

@ -8,7 +8,8 @@ function! s:prototype.split(...)
endfunction
function! s:prototype.add_section_spaced(group, contents)
call self.add_section(a:group, (g:airline_symbols.space).a:contents.(g:airline_symbols.space))
let spc = empty(a:contents) ? '' : g:airline_symbols.space
call self.add_section(a:group, spc.a:contents.spc)
endfunction
function! s:prototype.add_section(group, contents)
@ -37,12 +38,28 @@ function! s:prototype.build()
let i = 0
let length = len(self._sections)
let split = 0
let is_empty = 0
let prev_group = ''
while i < length
let section = self._sections[i]
let group = section[0]
let contents = section[1]
let pgroup = prev_group
let prev_group = s:get_prev_group(self._sections, i)
if is_empty
let prev_group = pgroup
endif
let is_empty = s:section_is_empty(self, contents)
if is_empty
" need to fix highlighting groups, since we
" have skipped a section, we actually need
" the previous previous group and so the
" seperator goes from the previous previous group
" to the current group
let pgroup = group
endif
if group == ''
let line .= contents
@ -54,12 +71,16 @@ function! s:prototype.build()
if prev_group == ''
let line .= '%#'.group.'#'
elseif split
let line .= s:get_transitioned_seperator(self, prev_group, group, side)
if !is_empty
let line .= s:get_transitioned_seperator(self, prev_group, group, side)
endif
let split = 0
else
let line .= s:get_seperator(self, prev_group, group, side)
if !is_empty
let line .= s:get_seperator(self, prev_group, group, side)
endif
endif
let line .= s:get_accented_line(self, group, contents)
let line .= is_empty ? '' : s:get_accented_line(self, group, contents)
endif
let i = i + 1
@ -118,6 +139,43 @@ function! s:get_accented_line(self, group, contents)
return line
endfunction
function! s:section_is_empty(self, content)
let start=1
" do not check for inactive windows
if a:self._context.active == 0
return 0
endif
" only check, if airline#skip_empty_sections == 1
if get(g:, 'airline_skip_empty_sections', 0) == 0
return 0
endif
" assume accents sections to be never empty
" (avoides, that on startup the mode message becomes empty)
if match(a:content, '%#__accent_[^#]*#.*__restore__#') > -1
return 0
endif
let list=matchlist(a:content, '%{\zs.\{-}\ze}', 1, start)
if empty(list)
return 0 " no function in statusline text
endif
while len(list) > 0
let expr = list[0]
try
" catch all exceptions, just in case
if !empty(eval(expr))
return 0
endif
catch
return 0
endtry
let start += 1
let list=matchlist(a:content, '%{\zs.\{-}\ze}', 1, start)
endw
return 1
endfunction
function! airline#builder#new(context)
let builder = copy(s:prototype)
let builder._context = a:context

View File

@ -123,7 +123,11 @@ function! airline#extensions#load()
if exists('g:airline_extensions')
for ext in g:airline_extensions
call airline#extensions#{ext}#init(s:ext)
try
call airline#extensions#{ext}#init(s:ext)
catch /^Vim\%((\a\+)\)\=:E117/ " E117, function does not exist
call airline#util#warning("Extension '".ext."' not installed, ignoring!")
endtry
endfor
return
endif

View File

@ -73,7 +73,7 @@ function! s:get_git_untracked(file)
if has_key(s:untracked_git, a:file)
let untracked = s:untracked_git[a:file]
else
let output = system('git status --porcelain -- '. a:file)
let output = system('git status --porcelain -- '. shellescape(a:file))
if output[0:1] is# '??' && output[3:-2] is? a:file
let untracked = get(g:, 'airline#extensions#branch#notexists', g:airline_symbols.notexists)
endif
@ -92,7 +92,7 @@ function! s:get_hg_untracked(file)
if has_key(s:untracked_hg, a:file)
let untracked = s:untracked_hg[a:file]
else
let untracked = (system('hg status -u -- '. a:file)[0] is# '?' ?
let untracked = (system('hg status -u -- '. shellescape(a:file))[0] is# '?' ?
\ get(g:, 'airline#extensions#branch#notexists', g:airline_symbols.notexists) : '')
let s:untracked_hg[a:file] = untracked
endif

View File

@ -22,6 +22,9 @@ function! s:get_section(winnr, key, ...)
endif
endif
let spc = g:airline_symbols.space
if !exists('g:airline_section_{a:key}')
return ''
endif
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
@ -40,7 +43,7 @@ endfunction
" deactivate it, until this is properly fixed:
" https://groups.google.com/d/msg/vim_dev/sb1jmVirXPU/mPhvDnZ-CwAJ
if s:section_use_groups && (v:version >= 704 || (v:version >= 703 && has('patch81')))
function s:add_section(builder, context, key)
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 == 'error' || a:key == 'warning') && empty(s:get_section(a:context.winnr, a:key)))
@ -56,7 +59,7 @@ if s:section_use_groups && (v:version >= 704 || (v:version >= 703 && has('patch8
endfunction
else
" older version don't like the use of %(%)
function s:add_section(builder, context, key)
function! s:add_section(builder, context, key)
if ((a:key == 'error' || a:key == 'warning') && empty(s:get_section(a:context.winnr, a:key)))
return
endif

View File

@ -15,6 +15,13 @@ endfunction
function! airline#extensions#quickfix#init(ext)
call a:ext.add_statusline_func('airline#extensions#quickfix#apply')
call a:ext.add_inactive_statusline_func('airline#extensions#quickfix#inactive_qf_window')
endfunction
function! airline#extensions#quickfix#inactive_qf_window(...)
if getbufvar(a:2.bufnr, '&filetype') is# 'qf' && !empty(getwinvar(a:2.winnr, 'quickfix_title', ''))
call setwinvar(a:2.winnr, 'airline_section_c', '[%{get(w:, "quickfix_title", "")}] %f %m')
endif
endfunction
function! s:get_text()

View File

@ -73,7 +73,7 @@ function! airline#extensions#tabline#buffers#get()
" Neovim feature: Have clickable buffers
if has("tablineat")
call b.add_raw('%'.nr.'@airline#extensions#tabline#buffers#switchbuf@')
call b.add_raw('%'.nr.'@airline#extensions#tabline#buffers#clickbuf@')
endif
if s:buffer_idx_mode
if len(s:number_map) > 0
@ -180,7 +180,7 @@ function! s:jump_to_tab(offset)
endif
endfunction
function s:map_keys()
function! s:map_keys()
if s:buffer_idx_mode
noremap <silent> <Plug>AirlineSelectTab1 :call <SID>select_tab(0)<CR>
noremap <silent> <Plug>AirlineSelectTab2 :call <SID>select_tab(1)<CR>
@ -196,10 +196,18 @@ function s:map_keys()
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
function! airline#extensions#tabline#buffers#clickbuf(minwid, clicks, button, modifiers) abort
" Clickable buffers
" works only in recent NeoVim with has('tablineat')
if a:clicks == 1 && a:button is# 'l' && a:modifiers !~# '[^ ]'
sil execute 'buffer' a:minwid
" single mouse button click without modifiers pressed
if a:clicks == 1 && a:modifiers !~# '[^ ]'
if a:button is# 'l'
" left button - switch to buffer
silent execute 'buffer' a:minwid
elseif a:button is# 'm'
" middle button - delete buffer
silent execute 'bdelete' a:minwid
endif
endif
endfunction

View File

@ -94,7 +94,7 @@ function! airline#extensions#tabline#tabs#get()
return s:current_tabline
endfunction
function s:map_keys()
function! s:map_keys()
noremap <silent> <Plug>AirlineSelectTab1 :1tabn<CR>
noremap <silent> <Plug>AirlineSelectTab2 :2tabn<CR>
noremap <silent> <Plug>AirlineSelectTab3 :3tabn<CR>

View File

@ -13,12 +13,9 @@ let s:long_format = get(g:, 'airline#extensions#whitespace#long_format', 'long[%
let s:mixed_indent_file_format = get(g:, 'airline#extensions#whitespace#mixed_indent_file_format', 'mix-indent-file[%s]')
let s:indent_algo = get(g:, 'airline#extensions#whitespace#mixed_indent_algo', 0)
let s:skip_check_ft = {'make': ['indent', 'mixed-indent-file'] }
let s:max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000)
let s:enabled = get(g:, 'airline#extensions#whitespace#enabled', 1)
let s:c_like_langs = ['c', 'cpp', 'cuda', 'java', 'javascript', 'ld']
let s:c_like_langs = get(g:, 'airline#extensions#c_like_langs', [ 'c', 'cpp', 'cuda', 'javascript', 'ld', 'php' ])
function! s:check_mixed_indent()
if s:indent_algo == 1
@ -139,7 +136,13 @@ function! airline#extensions#whitespace#init(...)
unlet! b:airline_whitespace_check
augroup airline_whitespace
autocmd!
autocmd CursorHold,BufWritePost * unlet! b:airline_whitespace_check
autocmd CursorHold,BufWritePost * call <sid>ws_refresh()
augroup END
endfunction
function! s:ws_refresh()
unlet! b:airline_whitespace_check
if get(g:, 'airline_skip_empty_sections', 0)
exe ':AirlineRefresh'
endif
endfunction

View File

@ -48,7 +48,7 @@ function! s:wordcount()
endif
endfunction
function s:get_decimal_group()
function! s:get_decimal_group()
if match(v:lang, '\v\cC|en') > -1
return ','
elseif match(v:lang, '\v\cde|dk|fr|pt') > -1

View File

@ -63,6 +63,7 @@ function! airline#init#bootstrap()
\ 'readonly': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a2" : 'RO',
\ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? "\u2739" : '!',
\ 'linenr': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a1" : ':',
\ 'maxlinenr': get(g:, 'airline_powerline_fonts', 0) ? "\u2630" : '',
\ 'branch': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a0" : '',
\ 'notexists': "\u2204",
\ 'modified': '+',
@ -88,6 +89,9 @@ function! airline#init#bootstrap()
call airline#parts#define('linenr', {
\ 'raw': '%{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#',
\ 'accent': 'bold'})
call airline#parts#define('maxlinenr', {
\ 'raw': '%#__accent_bold#/%L%{g:airline_symbols.maxlinenr}%#__restore__#',
\ 'accent': 'bold'})
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic',
\ 'eclim', 'whitespace','windowswap', 'ycm_error_count', 'ycm_warning_count'])
@ -97,8 +101,8 @@ function! airline#init#bootstrap()
endfunction
function! airline#init#gui_mode()
return ((has('nvim') && exists('$NVIM_TUI_ENABLE_TRUE_COLOR'))
\ || has('gui_running') || (has("termtruecolor") && &guicolors == 1)) ?
return ((has('nvim') && exists('$NVIM_TUI_ENABLE_TRUE_COLOR') && !exists("+termguicolors"))
\ || has('gui_running') || (has("termtruecolor") && &guicolors == 1) || (has("termguicolors") && &termguicolors == 1)) ?
\ 'gui' : 'cterm'
endfunction
@ -127,7 +131,7 @@ function! airline#init#sections()
let g:airline_section_y = airline#section#create_right(['ffenc'])
endif
if !exists('g:airline_section_z')
let g:airline_section_z = airline#section#create(['windowswap', '%3p%%'.spc, 'linenr', ':%3v '])
let g:airline_section_z = airline#section#create(['windowswap', '%3p%%'.spc, 'linenr', 'maxlinenr', spc.':%3v'])
endif
if !exists('g:airline_section_error')
let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic', 'eclim'])

View File

@ -19,6 +19,12 @@ function! airline#util#append(text, minwidth)
return empty(a:text) ? '' : prefix.g:airline_left_alt_sep.s:spc.a:text
endfunction
function! airline#util#warning(msg)
echohl WarningMsg
echomsg "airline: ".a:msg
echohl Normal
endfunction
function! airline#util#prepend(text, minwidth)
if a:minwidth > 0 && winwidth(0) < a:minwidth
return ''