mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:has_fugitive = exists('*fugitive#head')
|
||||
@ -9,6 +9,10 @@ if !s:has_fugitive && !s:has_lawrencium && !s:has_vcscommand
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:git_dirs = {}
|
||||
let s:untracked_git = {}
|
||||
let s:untracked_hg = {}
|
||||
|
||||
let s:head_format = get(g:, 'airline#extensions#branch#format', 0)
|
||||
if s:head_format == 1
|
||||
function! s:format_name(name)
|
||||
@ -28,71 +32,125 @@ else
|
||||
endfunction
|
||||
endif
|
||||
|
||||
let s:git_dirs = {}
|
||||
function! s:get_git_branch(path)
|
||||
if has_key(s:git_dirs, a:path)
|
||||
return s:git_dirs[a:path]
|
||||
if !s:has_fugitive
|
||||
return ''
|
||||
endif
|
||||
|
||||
let dir = fugitive#extract_git_dir(a:path)
|
||||
if empty(dir)
|
||||
let name = ''
|
||||
else
|
||||
try
|
||||
let line = join(readfile(dir . '/HEAD'))
|
||||
if strpart(line, 0, 16) == 'ref: refs/heads/'
|
||||
let name = strpart(line, 16)
|
||||
else
|
||||
" raw commit hash
|
||||
let name = strpart(line, 0, 7)
|
||||
endif
|
||||
catch
|
||||
let name = fugitive#head(7)
|
||||
if empty(name)
|
||||
if has_key(s:git_dirs, a:path)
|
||||
return s:git_dirs[a:path]
|
||||
endif
|
||||
|
||||
let dir = fugitive#extract_git_dir(a:path)
|
||||
if empty(dir)
|
||||
let name = ''
|
||||
endtry
|
||||
else
|
||||
try
|
||||
let line = join(readfile(dir . '/HEAD'))
|
||||
if strpart(line, 0, 16) == 'ref: refs/heads/'
|
||||
let name = strpart(line, 16)
|
||||
else
|
||||
" raw commit hash
|
||||
let name = strpart(line, 0, 7)
|
||||
endif
|
||||
catch
|
||||
let name = ''
|
||||
endtry
|
||||
endif
|
||||
endif
|
||||
|
||||
let s:git_dirs[a:path] = name
|
||||
return name
|
||||
endfunction
|
||||
|
||||
function! s:get_git_untracked(file)
|
||||
let untracked = ''
|
||||
if empty(a:file)
|
||||
return untracked
|
||||
endif
|
||||
if has_key(s:untracked_git, a:file)
|
||||
let untracked = s:untracked_git[a:file]
|
||||
else
|
||||
let output = system('git status --porcelain -- '. 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
|
||||
let s:untracked_git[a:file] = untracked
|
||||
endif
|
||||
return untracked
|
||||
endfunction
|
||||
|
||||
function! s:get_hg_untracked(file)
|
||||
if s:has_lawrencium
|
||||
" delete cache when unlet b:airline head?
|
||||
let untracked = ''
|
||||
if empty(a:file)
|
||||
return untracked
|
||||
endif
|
||||
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# '?' ?
|
||||
\ get(g:, 'airline#extensions#branch#notexists', g:airline_symbols.notexists) : '')
|
||||
let s:untracked_hg[a:file] = untracked
|
||||
endif
|
||||
return untracked
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:get_hg_branch()
|
||||
if s:has_lawrencium
|
||||
return lawrencium#statusline()
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#branch#head()
|
||||
if exists('b:airline_head') && !empty(b:airline_head)
|
||||
return b:airline_head
|
||||
endif
|
||||
|
||||
let b:airline_head = ''
|
||||
let l:heads = {}
|
||||
let l:vcs_priority = get(g:, "airline#extensions#branch#vcs_priority", ["git", "mercurial"])
|
||||
let found_fugitive_head = 0
|
||||
|
||||
if s:has_fugitive && !exists('b:mercurial_dir')
|
||||
let b:airline_head = fugitive#head(7)
|
||||
let l:git_head = s:get_git_branch(expand("%:p:h"))
|
||||
let l:hg_head = s:get_hg_branch()
|
||||
|
||||
if !empty(l:git_head)
|
||||
let found_fugitive_head = 1
|
||||
|
||||
if empty(b:airline_head) && !exists('b:git_dir')
|
||||
let b:airline_head = s:get_git_branch(expand("%:p:h"))
|
||||
endif
|
||||
let l:heads.git = (!empty(l:hg_head) ? "git:" : '') . s:format_name(l:git_head)
|
||||
let l:git_untracked = s:get_git_untracked(expand("%:p"))
|
||||
let l:heads.git .= l:git_untracked
|
||||
endif
|
||||
|
||||
if empty(b:airline_head)
|
||||
if s:has_lawrencium
|
||||
let b:airline_head = lawrencium#statusline()
|
||||
endif
|
||||
if !empty(l:hg_head)
|
||||
let l:heads.mercurial = (!empty(l:git_head) ? "hg:" : '') . s:format_name(l:hg_head)
|
||||
let l:hg_untracked = s:get_hg_untracked(expand("%:p"))
|
||||
let l:heads.mercurial.= l:hg_untracked
|
||||
endif
|
||||
|
||||
if empty(b:airline_head)
|
||||
if empty(l:heads)
|
||||
if s:has_vcscommand
|
||||
call VCSCommandEnableBufferSetup()
|
||||
if exists('b:VCSCommandBufferInfo')
|
||||
let b:airline_head = get(b:VCSCommandBufferInfo, 0, '')
|
||||
let b:airline_head = s:format_name(get(b:VCSCommandBufferInfo, 0, ''))
|
||||
endif
|
||||
endif
|
||||
else
|
||||
for vcs in l:vcs_priority
|
||||
if has_key(l:heads, vcs)
|
||||
if !empty(b:airline_head)
|
||||
let b:airline_head = b:airline_head . " | "
|
||||
endif
|
||||
let b:airline_head = b:airline_head . l:heads[vcs]
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if empty(b:airline_head) || !found_fugitive_head && !s:check_in_path()
|
||||
let b:airline_head = ''
|
||||
endif
|
||||
|
||||
let b:airline_head = s:format_name(b:airline_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
|
||||
@ -100,13 +158,15 @@ function! airline#extensions#branch#head()
|
||||
endif
|
||||
endif
|
||||
|
||||
if empty(b:airline_head) || !found_fugitive_head && !s:check_in_path()
|
||||
let b:airline_head = ''
|
||||
endif
|
||||
return b:airline_head
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#branch#get_head()
|
||||
let head = airline#extensions#branch#head()
|
||||
let empty_message = get(g:, 'airline#extensions#branch#empty_message',
|
||||
\ get(g:, 'airline_branch_empty_message', ''))
|
||||
let empty_message = get(g:, 'airline#extensions#branch#empty_message', '')
|
||||
let symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch)
|
||||
return empty(head)
|
||||
\ ? empty_message
|
||||
@ -136,9 +196,20 @@ function! s:check_in_path()
|
||||
return b:airline_file_in_root
|
||||
endfunction
|
||||
|
||||
function! s:reset_untracked_cache()
|
||||
if exists("s:untracked_git")
|
||||
let s:untracked_git={}
|
||||
endif
|
||||
if exists("s:untracked_hg")
|
||||
let s:untracked_hg={}
|
||||
endif
|
||||
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
|
||||
autocmd CursorHold,ShellCmdPost,CmdwinLeave * unlet! b:airline_head
|
||||
autocmd User AirlineBeforeRefresh unlet! b:airline_head
|
||||
autocmd BufWritePost,ShellCmdPost * call s:reset_untracked_cache()
|
||||
endfunction
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists('*bufferline#get_status_string')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !get(g:, 'command_t_loaded', 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !get(g:, 'loaded_csv', 0) && !exists(':Table')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !get(g:, 'loaded_ctrlp', 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:spc = g:airline_symbols.space
|
||||
@ -6,13 +6,12 @@ let s:padding = s:spc . s:spc . s:spc
|
||||
|
||||
function! airline#extensions#ctrlspace#statusline(...)
|
||||
let b = airline#builder#new({ 'active': 1 })
|
||||
call b.add_section('airline_a', s:padding . g:ctrlspace_symbols.cs . s:padding)
|
||||
call b.add_section('airline_b', s:padding . ctrlspace#statusline_mode_segment(s:padding))
|
||||
call b.add_section('airline_b', '⌗' . s:padding . ctrlspace#api#StatuslineModeSegment(s:padding))
|
||||
call b.split()
|
||||
call b.add_section('airline_x', s:spc . ctrlspace#statusline_tab_segment() . s:spc)
|
||||
call b.add_section('airline_x', s:spc . ctrlspace#api#StatuslineTabSegment() . s:spc)
|
||||
return b.build()
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#ctrlspace#init(ext)
|
||||
let g:ctrlspace_statusline_function = 'airline#extensions#ctrlspace#statusline()'
|
||||
let g:CtrlSpaceStatuslineFunction = "airline#extensions#ctrlspace#statusline()"
|
||||
endfunction
|
||||
|
@ -1,15 +1,18 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:section_use_groups = get(g:, 'airline#extensions#default#section_use_groupitems', 1)
|
||||
let s:section_truncate_width = get(g:, 'airline#extensions#default#section_truncate_width', {
|
||||
\ 'b': 79,
|
||||
\ 'x': 60,
|
||||
\ 'y': 88,
|
||||
\ 'z': 45,
|
||||
\ 'warning': 80,
|
||||
\ 'error': 80,
|
||||
\ })
|
||||
let s:layout = get(g:, 'airline#extensions#default#layout', [
|
||||
\ [ 'a', 'b', 'c' ],
|
||||
\ [ 'x', 'y', 'z', 'warning' ]
|
||||
\ [ 'x', 'y', 'z', 'warning', 'error' ]
|
||||
\ ])
|
||||
|
||||
function! s:get_section(winnr, key, ...)
|
||||
@ -26,30 +29,41 @@ endfunction
|
||||
|
||||
function! s:build_sections(builder, context, keys)
|
||||
for key in a:keys
|
||||
if key == 'warning' && !a:context.active
|
||||
if (key == 'warning' || key == 'error') && !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'))
|
||||
" There still is a highlighting bug when using groups %(%) in the statusline,
|
||||
" 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)
|
||||
" 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'
|
||||
if ((a:key == 'error' || a:key == 'warning') && empty(s:get_section(a:context.winnr, a:key)))
|
||||
return
|
||||
endif
|
||||
if (a:key == 'warning' || a:key == 'error')
|
||||
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'
|
||||
if (a:key == 'warning' || a:key == 'error')
|
||||
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 == 'error' || a:key == 'warning') && empty(s:get_section(a:context.winnr, a:key)))
|
||||
return
|
||||
endif
|
||||
if a:key == 'warning'
|
||||
call a:builder.add_raw('%#airline_warning#'.s:get_section(a:context.winnr, a:key))
|
||||
elseif a:key == 'error'
|
||||
call a:builder.add_raw('%#airline_error#'.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
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists(':ProjectCreate')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
" we don't actually want this loaded :P
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) && !get(g:, 'loaded_changes', 0) && !get(g:, 'loaded_quickfixsigns', 0)
|
||||
@ -44,22 +44,21 @@ 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'
|
||||
if !exists('b:source_func')
|
||||
if get(g:, 'loaded_signify') && sy#buffer_is_active()
|
||||
let b:source_func = 's:get_hunks_signify'
|
||||
elseif exists('*GitGutterGetHunkSummary')
|
||||
let s:source_func = 's:get_hunks_gitgutter'
|
||||
let b:source_func = 's:get_hunks_gitgutter'
|
||||
elseif exists('*changes#GetStats')
|
||||
let s:source_func = 's:get_hunks_changes'
|
||||
let b:source_func = 's:get_hunks_changes'
|
||||
elseif exists('*quickfixsigns#vcsdiff#GetHunkSummary')
|
||||
let s:source_func = 'quickfixsigns#vcsdiff#GetHunkSummary'
|
||||
let b:source_func = 'quickfixsigns#vcsdiff#GetHunkSummary'
|
||||
else
|
||||
let s:source_func = 's:get_hunks_empty'
|
||||
let b:source_func = 's:get_hunks_empty'
|
||||
endif
|
||||
endif
|
||||
return {s:source_func}()
|
||||
return {b:source_func}()
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#hunks#get_hunks()
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists(':NetrwSettings')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !get(g:, 'loaded_nrrw_rgn', 0)
|
||||
@ -39,7 +39,8 @@ function! airline#extensions#nrrwrgn#apply(...)
|
||||
endif
|
||||
endif
|
||||
let range=(dict.multi ? '' : printf("[%d-%d]", dict.start[1], dict.end[1]))
|
||||
call a:1.add_section('airline_c', printf("%s %s %s", name, range, dict.enabled ? "\u2713" : '!'))
|
||||
call a:1.add_section('airline_c', printf("%s %s %s", name, range,
|
||||
\ dict.enabled ? (&encoding ==? 'utf-8' ? "\u2713" : '') : '!'))
|
||||
call a:1.split()
|
||||
call a:1.add_section('airline_x', get(g:, 'airline_section_x').spc)
|
||||
call a:1.add_section('airline_y', spc.get(g:, 'airline_section_y').spc)
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists(':PromptlineSnapshot')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let g:airline#extensions#quickfix#quickfix_text = 'Quickfix'
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists(':SyntasticCheck')
|
||||
|
@ -1,15 +1,16 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
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
|
||||
endif
|
||||
|
||||
let s:ctrlspace = get(g:, 'CtrlSpaceLoaded', 0)
|
||||
|
||||
function! airline#extensions#tabline#init(ext)
|
||||
if has('gui_running')
|
||||
@ -27,31 +28,60 @@ function! s:toggle_off()
|
||||
call airline#extensions#tabline#autoshow#off()
|
||||
call airline#extensions#tabline#tabs#off()
|
||||
call airline#extensions#tabline#buffers#off()
|
||||
call airline#extensions#tabline#ctrlspace#off()
|
||||
endfunction
|
||||
|
||||
function! s:toggle_on()
|
||||
call airline#extensions#tabline#autoshow#on()
|
||||
call airline#extensions#tabline#tabs#on()
|
||||
call airline#extensions#tabline#buffers#on()
|
||||
call airline#extensions#tabline#ctrlspace#on()
|
||||
|
||||
set tabline=%!airline#extensions#tabline#get()
|
||||
endfunction
|
||||
|
||||
function! s:update_tabline()
|
||||
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)
|
||||
\ || 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
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#load_theme(palette)
|
||||
if pumvisible()
|
||||
return
|
||||
endif
|
||||
let colors = get(a:palette, 'tabline', {})
|
||||
" Theme for tabs on the left
|
||||
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)
|
||||
if has_key(a:palette, 'normal_modified') && has_key(a:palette.normal_modified, 'airline_c')
|
||||
let l:tabmodu = get(colors, 'airline_tabmod_unsel', a:palette.normal_modified.airline_c)
|
||||
else
|
||||
"Fall back to normal airline_c if modified airline_c isn't present
|
||||
let l:tabmodu = get(colors, 'airline_tabmod_unsel', a:palette.normal.airline_c)
|
||||
endif
|
||||
|
||||
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)
|
||||
@ -59,6 +89,21 @@ function! airline#extensions#tabline#load_theme(palette)
|
||||
call airline#highlighter#exec('airline_tabmod', l:tabmod)
|
||||
call airline#highlighter#exec('airline_tabmod_unsel', l:tabmodu)
|
||||
call airline#highlighter#exec('airline_tabhid', l:tabhid)
|
||||
|
||||
" Theme for tabs on the right
|
||||
let l:tabsel_right = get(colors, 'airline_tabsel_right', a:palette.normal.airline_a)
|
||||
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')
|
||||
let l:tabmodu_right = get(colors, 'airline_tabmod_unsel_right', a:palette.normal_modified.airline_c)
|
||||
else
|
||||
"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_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)
|
||||
call airline#highlighter#exec('airline_tabmod_unsel_right', l:tabmodu_right)
|
||||
endfunction
|
||||
|
||||
let s:current_tabcnt = -1
|
||||
@ -68,9 +113,15 @@ function! airline#extensions#tabline#get()
|
||||
let s:current_tabcnt = curtabcnt
|
||||
call airline#extensions#tabline#tabs#invalidate()
|
||||
call airline#extensions#tabline#buffers#invalidate()
|
||||
call airline#extensions#tabline#ctrlspace#invalidate()
|
||||
endif
|
||||
|
||||
if s:show_buffers && curtabcnt == 1 || !s:show_tabs
|
||||
if !exists('#airline#BufAdd#*')
|
||||
autocmd airline BufAdd * call <sid>update_tabline()
|
||||
endif
|
||||
if s:ctrlspace
|
||||
return airline#extensions#tabline#ctrlspace#get()
|
||||
elseif s:show_buffers && curtabcnt == 1 || !s:show_tabs
|
||||
return airline#extensions#tabline#buffers#get()
|
||||
else
|
||||
return airline#extensions#tabline#tabs#get()
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
|
||||
@ -22,7 +22,9 @@ function! airline#extensions#tabline#autoshow#on()
|
||||
augroup airline_tabline_autoshow
|
||||
autocmd!
|
||||
if s:buf_min_count <= 0 && s:tab_min_count <= 1
|
||||
set showtabline=2
|
||||
if &lines > 3
|
||||
set showtabline=2
|
||||
endif
|
||||
else
|
||||
if s:show_buffers == 1
|
||||
autocmd BufEnter * call <sid>show_tabline(s:buf_min_count, len(airline#extensions#tabline#buflist#list()))
|
||||
@ -40,7 +42,7 @@ endfunction
|
||||
|
||||
function! s:show_tabline(min_count, total_count)
|
||||
if a:total_count >= a:min_count
|
||||
if &showtabline != 2
|
||||
if &showtabline != 2 && &lines > 3
|
||||
set showtabline=2
|
||||
endif
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
scriptencoding utf-8
|
||||
@ -37,6 +37,8 @@ function! airline#extensions#tabline#buffers#on()
|
||||
augroup airline_tabline_buffers
|
||||
autocmd!
|
||||
autocmd BufDelete * call airline#extensions#tabline#buffers#invalidate()
|
||||
autocmd User BufMRUChange call airline#extensions#tabline#buflist#invalidate()
|
||||
autocmd User BufMRUChange call airline#extensions#tabline#buffers#invalidate()
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
@ -45,6 +47,7 @@ function! airline#extensions#tabline#buffers#invalidate()
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#buffers#get()
|
||||
call <sid>map_keys()
|
||||
let cur = bufnr('%')
|
||||
if cur == s:current_bufnr
|
||||
if !g:airline_detect_modified || getbufvar(cur, '&modified') == s:current_modified
|
||||
@ -180,16 +183,18 @@ function! s:jump_to_tab(offset)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if s:buffer_idx_mode
|
||||
noremap <unique> <Plug>AirlineSelectTab1 :call <SID>select_tab(0)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab2 :call <SID>select_tab(1)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab3 :call <SID>select_tab(2)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab4 :call <SID>select_tab(3)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab5 :call <SID>select_tab(4)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab6 :call <SID>select_tab(5)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab7 :call <SID>select_tab(6)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab8 :call <SID>select_tab(7)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectTab9 :call <SID>select_tab(8)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectPrevTab :<C-u>call <SID>jump_to_tab(-v:count1)<CR>
|
||||
noremap <unique> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
|
||||
endif
|
||||
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>
|
||||
noremap <silent> <Plug>AirlineSelectTab3 :call <SID>select_tab(2)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab4 :call <SID>select_tab(3)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab5 :call <SID>select_tab(4)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab6 :call <SID>select_tab(5)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab7 :call <SID>select_tab(6)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab8 :call <SID>select_tab(7)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab9 :call <SID>select_tab(8)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectPrevTab :<C-u>call <SID>jump_to_tab(-v:count1)<CR>
|
||||
noremap <silent> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
|
||||
endif
|
||||
endfunction
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:excludes = get(g:, 'airline#extensions#tabline#excludes', [])
|
||||
@ -13,26 +13,26 @@ function! airline#extensions#tabline#buflist#list()
|
||||
return s:current_buffer_list
|
||||
endif
|
||||
|
||||
let list = (exists('g:did_bufmru') && g:did_bufmru) ? BufMRUList() : range(1, bufnr("$"))
|
||||
|
||||
let buffers = []
|
||||
let cur = bufnr('%')
|
||||
for nr in range(1, bufnr('$'))
|
||||
if buflisted(nr) && bufexists(nr)
|
||||
let toadd = 1
|
||||
for ex in s:excludes
|
||||
if match(bufname(nr), ex) >= 0
|
||||
let toadd = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if getbufvar(nr, 'current_syntax') == 'qf'
|
||||
let toadd = 0
|
||||
endif
|
||||
if s:exclude_preview && getbufvar(nr, '&bufhidden') == 'wipe' && getbufvar(nr, '&buftype') == 'nofile'
|
||||
let toadd = 0
|
||||
endif
|
||||
if toadd
|
||||
call add(buffers, nr)
|
||||
" If this is too slow, we can switch to a different algorithm.
|
||||
" Basically branch 535 already does it, but since it relies on
|
||||
" BufAdd autocommand, I'd like to avoid this if possible.
|
||||
for nr in list
|
||||
if buflisted(nr)
|
||||
" Do not add to the bufferlist, if either
|
||||
" 1) buffername matches exclude pattern
|
||||
" 2) buffer is a quickfix buffer
|
||||
" 3) exclude preview windows (if 'bufhidden' == wipe
|
||||
" and 'buftype' == nofile
|
||||
if (!empty(s:excludes) && match(bufname(nr), join(s:excludes, '\|')) > -1) ||
|
||||
\ (getbufvar(nr, 'current_syntax') == 'qf') ||
|
||||
\ (s:exclude_preview && getbufvar(nr, '&bufhidden') == 'wipe'
|
||||
\ && getbufvar(nr, '&buftype') == 'nofile')
|
||||
continue
|
||||
endif
|
||||
call add(buffers, nr)
|
||||
endif
|
||||
endfor
|
||||
|
||||
|
@ -0,0 +1,97 @@
|
||||
" MIT License. Copyright (c) 2016 Kevin Sapper
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:current_bufnr = -1
|
||||
let s:current_tabnr = -1
|
||||
let s:current_tabline = ''
|
||||
|
||||
function! airline#extensions#tabline#ctrlspace#off()
|
||||
augroup airline_tabline_ctrlspace
|
||||
autocmd!
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#ctrlspace#on()
|
||||
augroup airline_tabline_ctrlspace
|
||||
autocmd!
|
||||
autocmd BufDelete * call airline#extensions#tabline#ctrlspace#invalidate()
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#ctrlspace#invalidate()
|
||||
let s:current_bufnr = -1
|
||||
let s:current_tabnr = -1
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#ctrlspace#get()
|
||||
let cur_buf = bufnr('%')
|
||||
|
||||
let s:tab_list = ctrlspace#api#TabList()
|
||||
for tab in s:tab_list
|
||||
if tab.current
|
||||
let cur_tab = tab.index
|
||||
endif
|
||||
endfor
|
||||
|
||||
if cur_buf == s:current_bufnr && cur_tab == s:current_tabnr
|
||||
return s:current_tabline
|
||||
endif
|
||||
|
||||
let b = 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
|
||||
else
|
||||
if tab.modified
|
||||
let group = 'airline_tabmod_unsel_right'
|
||||
else
|
||||
let group = 'airline_tabhid_right'
|
||||
endif
|
||||
endif
|
||||
|
||||
call b.add_section_spaced(group, tab.title.ctrlspace#api#TabBuffersNumber(tab.index))
|
||||
endfor
|
||||
|
||||
call b.add_section_spaced('airline_tabtype', 'tabs')
|
||||
|
||||
let s:current_bufnr = cur_buf
|
||||
let s:current_tabnr = cur_tab
|
||||
let s:current_tabline = b.build()
|
||||
return s:current_tabline
|
||||
endfunction
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
function! airline#extensions#tabline#formatters#unique_tail#format(bufnr, buffers)
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
scriptencoding utf-8
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" 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)
|
||||
@ -31,6 +31,7 @@ endfunction
|
||||
function! airline#extensions#tabline#tabs#get()
|
||||
let curbuf = bufnr('%')
|
||||
let curtab = tabpagenr()
|
||||
call s:map_keys()
|
||||
if curbuf == s:current_bufnr && curtab == s:current_tabnr
|
||||
if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified
|
||||
return s:current_tabline
|
||||
@ -80,3 +81,18 @@ function! airline#extensions#tabline#tabs#get()
|
||||
let s:current_tabline = b.build()
|
||||
return s:current_tabline
|
||||
endfunction
|
||||
|
||||
function s:map_keys()
|
||||
noremap <silent> <Plug>AirlineSelectTab1 :1tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab2 :2tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab3 :3tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab4 :4tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab5 :5tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab6 :6tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab7 :7tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab8 :8tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectTab9 :9tabn<CR>
|
||||
noremap <silent> <Plug>AirlineSelectPrevTab gT
|
||||
" tabn {count} goes to count tab does not go {count} tab pages forward!
|
||||
noremap <silent> <Plug>AirlineSelectNextTab :<C-U>exe repeat(':tabn\|', v:count1)<cr>
|
||||
endfunction
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists(':TagbarToggle')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists(':Tmuxline')
|
||||
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !exists(':UndotreeToggle')
|
||||
|
@ -0,0 +1,22 @@
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !get(g:, 'loaded_unicodePlugin', 0)
|
||||
finish
|
||||
endif
|
||||
|
||||
function! airline#extensions#unicode#apply(...)
|
||||
if exists(":UnicodeTable") == 2 && bufname('') ==# 'UnicodeTable'
|
||||
call airline#parts#define('unicode', {
|
||||
\ 'text': '[UnicodeTable]',
|
||||
\ 'accent': 'bold' })
|
||||
let w:airline_section_a = airline#section#create(['unicode'])
|
||||
let w:airline_section_b = ''
|
||||
let w:airline_section_c = ''
|
||||
let w:airline_section_y = ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#unicode#init(ext)
|
||||
call a:ext.add_statusline_func('airline#extensions#unicode#apply')
|
||||
endfunction
|
@ -1,4 +1,4 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !get(g:, 'loaded_unite', 0)
|
||||
|
@ -1,10 +1,6 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
if !isdirectory($VIRTUAL_ENV)
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:spc = g:airline_symbols.space
|
||||
|
||||
function! airline#extensions#virtualenv#init(ext)
|
||||
@ -12,14 +8,22 @@ function! airline#extensions#virtualenv#init(ext)
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#virtualenv#apply(...)
|
||||
if &filetype =~ "python"
|
||||
if &filetype =~# "python"
|
||||
if get(g:, 'virtualenv_loaded', 0)
|
||||
let statusline = virtualenv#statusline()
|
||||
else
|
||||
let statusline = fnamemodify($VIRTUAL_ENV, ':t')
|
||||
endif
|
||||
call airline#extensions#append_to_section('x',
|
||||
\ s:spc.g:airline_right_alt_sep.s:spc.statusline)
|
||||
if !empty(statusline)
|
||||
call airline#extensions#append_to_section('x',
|
||||
\ s:spc.g:airline_right_alt_sep.s:spc.statusline)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#virtualenv#update()
|
||||
if &filetype =~# "python"
|
||||
call airline#extensions#virtualenv#apply()
|
||||
call airline#update_statusline()
|
||||
endif
|
||||
endfunction
|
||||
|
@ -1,22 +1,18 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 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:show_message = get(g:, 'airline#extensions#whitespace#show_message', 1)
|
||||
let s:symbol = get(g:, 'airline#extensions#whitespace#symbol', g:airline_symbols.whitespace)
|
||||
let s:default_checks = ['indent', 'trailing']
|
||||
let s:default_checks = ['indent', 'trailing', 'mixed-indent-file']
|
||||
|
||||
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:long_format = get(g:, 'airline#extensions#whitespace#long_format', 'long[%s]')
|
||||
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)
|
||||
|
||||
@ -38,6 +34,16 @@ function! s:check_mixed_indent()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:check_mixed_indent_file()
|
||||
let indent_tabs = search('\v(^\t+)', 'nw')
|
||||
let indent_spc = search('\v(^ +)', 'nw')
|
||||
if indent_tabs > 0 && indent_spc > 0
|
||||
return printf("%d:%d", indent_tabs, indent_spc)
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#whitespace#check()
|
||||
if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines
|
||||
return ''
|
||||
@ -49,20 +55,34 @@ function! airline#extensions#whitespace#check()
|
||||
|
||||
let trailing = 0
|
||||
if index(checks, 'trailing') > -1
|
||||
let trailing = search('\s$', 'nw')
|
||||
try
|
||||
let regexp = get(g:, 'airline#extensions#whitespace#trailing_regexp', '\s$')
|
||||
let trailing = search(regexp, 'nw')
|
||||
catch
|
||||
echomsg 'airline#whitespace: error occured evaluating '. regexp
|
||||
echomsg v:exception
|
||||
return ''
|
||||
endtry
|
||||
endif
|
||||
|
||||
let mixed = 0
|
||||
if index(checks, 'indent') > -1
|
||||
let check = 'indent'
|
||||
if index(checks, check) > -1 && index(get(s:skip_check_ft, &ft, []), check) < 0
|
||||
let mixed = s:check_mixed_indent()
|
||||
endif
|
||||
|
||||
let mixed_file = ''
|
||||
let check = 'mixed-indent-file'
|
||||
if index(checks, check) > -1 && index(get(s:skip_check_ft, &ft, []), check) < 0
|
||||
let mixed_file = s:check_mixed_indent_file()
|
||||
endif
|
||||
|
||||
let long = 0
|
||||
if index(checks, 'long') > -1 && &tw > 0
|
||||
let long = search('\%>'.&tw.'v.\+', 'nw')
|
||||
endif
|
||||
|
||||
if trailing != 0 || mixed != 0 || long != 0
|
||||
if trailing != 0 || mixed != 0 || long != 0 || !empty(mixed_file)
|
||||
let b:airline_whitespace_check = s:symbol
|
||||
if s:show_message
|
||||
if trailing != 0
|
||||
@ -74,6 +94,9 @@ function! airline#extensions#whitespace#check()
|
||||
if long != 0
|
||||
let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:long_format, long)
|
||||
endif
|
||||
if !empty(mixed_file)
|
||||
let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_file_format, mixed_file)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
@ -1,33 +1,26 @@
|
||||
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:filetypes = get(g:, 'airline#extensions#wordcount#filetypes', '\vhelp|markdown|rst|org')
|
||||
let s:filetypes = get(g:, 'airline#extensions#wordcount#filetypes', '\vhelp|markdown|rst|org|text')
|
||||
let s:format = get(g:, 'airline#extensions#wordcount#format', '%d words')
|
||||
let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')
|
||||
|
||||
" adapted from http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
|
||||
function! s:update()
|
||||
if &ft !~ s:filetypes
|
||||
unlet! b:airline_wordcount
|
||||
return
|
||||
elseif mode() =~? 's'
|
||||
" Bail on select mode
|
||||
return
|
||||
endif
|
||||
|
||||
let old_status = v:statusmsg
|
||||
let position = getpos(".")
|
||||
exe "silent normal! g\<c-g>"
|
||||
let stat = v:statusmsg
|
||||
call setpos('.', position)
|
||||
let v:statusmsg = old_status
|
||||
|
||||
let parts = split(stat)
|
||||
if len(parts) > 11
|
||||
let cnt = str2nr(split(stat)[11])
|
||||
let spc = g:airline_symbols.space
|
||||
let b:airline_wordcount = printf(s:format, cnt) . spc . g:airline_right_alt_sep . spc
|
||||
else
|
||||
unlet! b:airline_wordcount
|
||||
if match(&ft, s:filetypes) > -1
|
||||
let l:mode = mode()
|
||||
if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S'
|
||||
let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
|
||||
let b:airline_change_tick = b:changedtick
|
||||
else
|
||||
if get(b:, 'airline_wordcount_cache', '') is# '' ||
|
||||
\ b:airline_wordcount_cache isnot# get(b:, 'airline_wordcount', '') ||
|
||||
\ get(b:, 'airline_change_tick', 0) != b:changedtick
|
||||
" cache data
|
||||
let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
|
||||
let b:airline_wordcount_cache = b:airline_wordcount
|
||||
let b:airline_change_tick = b:changedtick
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -41,4 +34,3 @@ function! airline#extensions#wordcount#init(ext)
|
||||
call a:ext.add_statusline_func('airline#extensions#wordcount#apply')
|
||||
autocmd BufReadPost,CursorMoved,CursorMovedI * call s:update()
|
||||
endfunction
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
function! airline#extensions#wordcount#formatters#default#format()
|
||||
let words = string(s:wordcount())
|
||||
if empty(words)
|
||||
return
|
||||
endif
|
||||
let separator = s:get_decimal_group()
|
||||
if words > 999 && !empty(separator)
|
||||
" Format number according to locale, e.g. German: 1.245 or English: 1,245
|
||||
let a = join(reverse(split(words, '.\zs')),'')
|
||||
let a = substitute(a, '...', '&'.separator, 'g')
|
||||
let words = join(reverse(split(a, '.\zs')),'')
|
||||
endif
|
||||
return words . " words" . g:airline_symbols.space . g:airline_right_alt_sep . g:airline_symbols.space
|
||||
endfunction
|
||||
|
||||
function! s:wordcount()
|
||||
if exists("*wordcount")
|
||||
let l:mode = mode()
|
||||
if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S'
|
||||
let l:visual_words = wordcount()['visual_words']
|
||||
if l:visual_words != ''
|
||||
return l:visual_words
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
else
|
||||
return wordcount()['words']
|
||||
endif
|
||||
elseif mode() =~? 's'
|
||||
return
|
||||
else
|
||||
let old_status = v:statusmsg
|
||||
let position = getpos(".")
|
||||
exe "silent normal! g\<c-g>"
|
||||
let stat = v:statusmsg
|
||||
call setpos('.', position)
|
||||
let v:statusmsg = old_status
|
||||
|
||||
let parts = split(stat)
|
||||
if len(parts) > 11
|
||||
return str2nr(parts[11])
|
||||
else
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function s:get_decimal_group()
|
||||
if match(v:lang, '\v\cC|en') > -1
|
||||
return ','
|
||||
elseif match(v:lang, '\v\cde|dk|fr|pt') > -1
|
||||
return '.'
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
@ -0,0 +1,36 @@
|
||||
" MIT License. Copyright (c) 2015 Evgeny Firsov.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
let s:spc = g:airline_symbols.space
|
||||
let s:error_symbol = get(g:, 'airline#extensions#ycm#error_symbol', 'E:')
|
||||
let s:warning_symbol = get(g:, 'airline#extensions#ycm#warning_symbol', 'W:')
|
||||
|
||||
function! airline#extensions#ycm#init(ext)
|
||||
call airline#parts#define_function('ycm_error_count', 'airline#extensions#ycm#get_error_count')
|
||||
call airline#parts#define_function('ycm_warning_count', 'airline#extensions#ycm#get_warning_count')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#ycm#get_error_count()
|
||||
if exists(':YcmDiag')
|
||||
let cnt = youcompleteme#GetErrorCount()
|
||||
|
||||
if cnt != 0
|
||||
return s:error_symbol.cnt
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#ycm#get_warning_count()
|
||||
if exists(':YcmDiag')
|
||||
let cnt = youcompleteme#GetWarningCount()
|
||||
|
||||
if cnt != 0
|
||||
return s:warning_symbol.cnt.s:spc
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
Reference in New Issue
Block a user