1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Updated plugins. Fixed some issues related to empty space and peaksea. Using Source Code Pro as default font

This commit is contained in:
amix
2013-12-28 18:23:13 +00:00
parent 86f4456be1
commit 08a64d943d
35 changed files with 553 additions and 90 deletions

View File

@ -14,7 +14,7 @@ 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()
function! airline#extensions#branch#head()
let head = ''
if s:has_fugitive && !exists('b:mercurial_dir')
@ -42,6 +42,13 @@ function! airline#extensions#branch#get_head()
endif
return empty(head) || !s:check_in_path()
\ ? ''
\ : head
endfunction
function! airline#extensions#branch#get_head()
let head = airline#extensions#branch#head()
return empty(head)
\ ? s:empty_message
\ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.(g:airline_symbols.space), head)
endfunction

View File

@ -17,12 +17,18 @@ 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)
" Remove any non-eclim signs (see eclim#display#signs#Update)
call filter(eclimList, "v:val.name =~ '^\(qf_\)\?\(error\|info\|warning\)$'")
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
endif
return ''

View File

@ -16,8 +16,12 @@ function! s:get_hunks_signify()
return []
endfunction
function! s:is_branch_empty()
return exists('*airline#extensions#branch#head') && empty(airline#extensions#branch#head())
endfunction
function! s:get_hunks_gitgutter()
if !get(g:, 'gitgutter_enabled', 0)
if !get(g:, 'gitgutter_enabled', 0) || s:is_branch_empty()
return ''
endif
return GitGutterGetHunkSummary()

View File

@ -24,7 +24,7 @@ function! s:get_text()
let nr = bufnr('%')
for buf in split(buffers, '\n')
if match(buf, '\v^\s+'.nr) > -1
if match(buf, '\v^\s*'.nr) > -1
if match(buf, '\[Quickfix List\]') > -1
return g:airline#extensions#quickfix#quickfix_text
else

View File

@ -5,6 +5,7 @@ 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:show_tab_nr = get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
let s:builder_context = {
\ 'active' : 1,
@ -103,7 +104,7 @@ function! airline#extensions#tabline#title(n)
endfunction
function! airline#extensions#tabline#get_buffer_name(nr)
return airline#extensions#tabline#formatters#{s:formatter}(a:nr, get(s:, 'current_buffer_list', []))
return airline#extensions#tabline#{s:formatter}#format(a:nr, get(s:, 'current_buffer_list', s:get_buffer_list()))
endfunction
function! s:get_buffer_list()
@ -179,9 +180,16 @@ function! s:get_visible_buffers()
return buffers
endfunction
let s:current_bufnr = -1
let s:current_tabnr = -1
let s:current_tabline = ''
function! s:get_buffers()
let b = airline#builder#new(s:builder_context)
let cur = bufnr('%')
if cur == s:current_bufnr
return s:current_tabline
endif
let b = airline#builder#new(s:builder_context)
let tab_bufs = tabpagebuflist(tabpagenr())
for nr in s:get_visible_buffers()
if nr < 0
@ -207,13 +215,22 @@ function! s:get_buffers()
call b.add_section('airline_tabfill', '')
call b.split()
call b.add_section('airline_tabtype', ' buffers ')
return b.build()
let s:current_bufnr = cur
let s:current_tabline = b.build()
return s:current_tabline
endfunction
function! s:get_tabs()
let curbuf = bufnr('%')
let curtab = tabpagenr()
if curbuf == s:current_bufnr && curtab == s:current_tabnr
return s:current_tabline
endif
let b = airline#builder#new(s:builder_context)
for i in range(1, tabpagenr('$'))
if i == tabpagenr()
if i == curtab
let group = 'airline_tabsel'
if g:airline_detect_modified
for bi in tabpagebuflist(i)
@ -226,18 +243,24 @@ function! s:get_tabs()
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
if s:show_tab_nr
if s:tab_nr_type == 0
let val .= ' %{len(tabpagebuflist('.i.'))}'
else
let val .= (g:airline_symbols.space).i
endif
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
let s:current_bufnr = curbuf
let s:current_tabnr = curtab
let s:current_tabline = b.build()
return s:current_tabline
endfunction

View File

@ -7,7 +7,7 @@ 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)
function! airline#extensions#tabline#default#format(bufnr, buffers)
let _ = ''
let name = bufname(a:bufnr)
@ -21,40 +21,15 @@ function! airline#extensions#tabline#formatters#default(bufnr, buffers)
endif
endif
return s:wrap_name(a:bufnr, _)
return airline#extensions#tabline#default#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)
function! airline#extensions#tabline#default#wrap_name(bufnr, buffer_name)
let _ = s:buf_nr_show ? printf(s:buf_nr_format, a:bufnr) : ''
let _ .= a:buffer_name
let _ .= substitute(a:buffer_name, '\\', '/', 'g')
if getbufvar(a:bufnr, '&modified') == 1
let _ .= s:buf_modified_symbol
endif
return _
endfunction

View File

@ -0,0 +1,27 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#extensions#tabline#unique_tail#format(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] = airline#extensions#tabline#default#wrap_name(nr, tail)
endif
endfor
for nr in values(duplicates)
let map[nr] = airline#extensions#tabline#default#wrap_name(nr, fnamemodify(bufname(nr), ':p:.'))
endfor
return map[a:bufnr]
endfunction

View File

@ -0,0 +1,88 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:skip_symbol = '…'
function! airline#extensions#tabline#unique_tail_improved#format(bufnr, buffers)
if len(a:buffers) <= 1 " don't need to compare bufnames if has less than one buffer opened
return airline#extensions#tabline#default#format(a:bufnr, a:buffers)
endif
let curbuf_tail = fnamemodify(bufname(a:bufnr), ':t')
let do_deduplicate = 0
let path_tokens = {}
for nr in a:buffers
let name = bufname(nr)
if !empty(name) && nr != a:bufnr && fnamemodify(name, ':t') == curbuf_tail
let do_deduplicate = 1
let tokens = reverse(split(substitute(fnamemodify(name, ':p:.:h'), '\\', '/', 'g'), '/'))
let token_index = 0
for token in tokens
if token == '.' | break | endif
if !has_key(path_tokens, token_index)
let path_tokens[token_index] = {}
endif
let path_tokens[token_index][token] = 1
let token_index += 1
endfor
endif
endfor
if do_deduplicate == 1
let path = []
let token_index = 0
for token in reverse(split(substitute(fnamemodify(bufname(a:bufnr), ':p:.:h'), '\\', '/', 'g'), '/'))
if token == '.' | break | endif
let duplicated = 0
let uniq = 1
let single = 1
if has_key(path_tokens, token_index)
let duplicated = 1
if len(keys(path_tokens[token_index])) > 1 | let single = 0 | endif
if has_key(path_tokens[token_index], token) | let uniq = 0 | endif
endif
call insert(path, {'token': token, 'duplicated': duplicated, 'uniq': uniq, 'single': single})
let token_index += 1
endfor
let buf_name = [curbuf_tail]
let has_uniq = 0
let has_skipped = 0
for token1 in reverse(path)
if !token1['duplicated'] && len(buf_name) > 1
call insert(buf_name, s:skip_symbol)
let has_skipped = 0
break
endif
if has_uniq == 1
call insert(buf_name, s:skip_symbol)
let has_skipped = 0
break
endif
if token1['uniq'] == 0 && token1['single'] == 1
let has_skipped = 1
else
if has_skipped == 1
call insert(buf_name, s:skip_symbol)
let has_skipped = 0
endif
call insert(buf_name, token1['token'])
endif
if token1['uniq'] == 1
let has_uniq = 1
endif
endfor
if has_skipped == 1
call insert(buf_name, s:skip_symbol)
endif
return airline#extensions#tabline#default#wrap_name(a:bufnr, join(buf_name, '/'))
else
return airline#extensions#tabline#default#format(a:bufnr, a:buffers)
endif
endfunction

View File

@ -0,0 +1,26 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
if !exists(':Tmuxline')
finish
endif
let s:tmuxline_snapshot_file = get(g:, 'airline#extensions#tmuxline#snapshot_file', '')
let s:color_template = get(g:, 'airline#extensions#tmuxline#color_template', 'normal')
function! airline#extensions#tmuxline#init(ext)
call a:ext.add_theme_func('airline#extensions#tmuxline#set_tmux_colors')
endfunction
function! airline#extensions#tmuxline#set_tmux_colors(palette)
let color_template = has_key(a:palette, s:color_template) ? s:color_template : 'normal'
let mode_palette = a:palette[color_template]
let tmuxline_theme = tmuxline#api#create_theme_from_airline(mode_palette)
call tmuxline#api#set_theme(tmuxline_theme)
if strlen(s:tmuxline_snapshot_file)
call tmuxline#api#snapshot(s:tmuxline_snapshot_file)
endif
endfunction

View File

@ -16,10 +16,12 @@ 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:max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000)
let s:enabled = 1
function! airline#extensions#whitespace#check()
if &readonly || !&modifiable || !s:enabled
if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines
return ''
endif