commit
68331a5e4f
|
@ -1 +1,3 @@
|
||||||
doc/tags
|
doc/tags
|
||||||
|
*.lock
|
||||||
|
.vim-flavor
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
language: ruby
|
||||||
|
rvm:
|
||||||
|
- 1.9.3
|
||||||
|
script: rake ci
|
|
@ -0,0 +1,2 @@
|
||||||
|
source 'https://rubygems.org'
|
||||||
|
gem 'vim-flavor', '~> 1.1'
|
|
@ -14,6 +14,8 @@ Lean & mean statusline for vim that's light as air.
|
||||||
* Supports 7.2 as the minimum Vim version.
|
* Supports 7.2 as the minimum Vim version.
|
||||||
* Stable release cycle; bleeding edge changes happen on the `dev` branch, and after they have gone through a [full regression test][33] will eventually be merged in the stable master branch. Releases typically occur every 2 weeks.
|
* Stable release cycle; bleeding edge changes happen on the `dev` branch, and after they have gone through a [full regression test][33] will eventually be merged in the stable master branch. Releases typically occur every 2 weeks.
|
||||||
|
|
||||||
|
[](https://travis-ci.org/bling/vim-airline)
|
||||||
|
|
||||||
## Straightforward customization
|
## Straightforward customization
|
||||||
|
|
||||||
If you don't like the defaults, you can replace all sections with standard `statusline` syntax. Give your statusline that you've built over the years a face lift.
|
If you don't like the defaults, you can replace all sections with standard `statusline` syntax. Give your statusline that you've built over the years a face lift.
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env rake
|
||||||
|
|
||||||
|
task :default => [:test]
|
||||||
|
|
||||||
|
task :ci => [:dump, :test]
|
||||||
|
|
||||||
|
task :dump do
|
||||||
|
sh 'vim --version'
|
||||||
|
end
|
||||||
|
|
||||||
|
task :test do
|
||||||
|
sh 'bundle exec vim-flavor test'
|
||||||
|
end
|
||||||
|
|
|
@ -27,10 +27,12 @@ function! airline#extensions#branch#get_head()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return empty(head) ? s:empty_message : s:symbol.' '.head
|
return empty(head)
|
||||||
|
\ ? s:empty_message
|
||||||
|
\ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.' ', head)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#branch#init(ext)
|
function! airline#extensions#branch#init(ext)
|
||||||
let g:airline_parts.branch = '%{airline#extensions#branch#get_head()}'
|
call airline#parts#define_function('branch', 'airline#extensions#branch#get_head')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,6 @@ function! airline#extensions#bufferline#init(ext)
|
||||||
let g:bufferline_separator = ' '
|
let g:bufferline_separator = ' '
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let g:airline_parts.file = '%{bufferline#refresh_status()}'.bufferline#get_status_string()
|
call airline#parts#define_raw('file', '%{bufferline#refresh_status()}'.bufferline#get_status_string())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ function! airline#extensions#example#init(ext)
|
||||||
|
|
||||||
" Here we define a new part for the plugin. This allows users to place this
|
" Here we define a new part for the plugin. This allows users to place this
|
||||||
" extension in arbitrary locations.
|
" extension in arbitrary locations.
|
||||||
let g:airline_parts.cats = '%{airline#extensions#example#get_cats()}'
|
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
|
" Next up we add a funcref so that we can run some code prior to the
|
||||||
" statusline getting modifed.
|
" statusline getting modifed.
|
||||||
|
@ -28,7 +28,7 @@ function! airline#extensions#example#apply(...)
|
||||||
" Let's use a helper function. It will take care of ensuring that the
|
" Let's use a helper function. It will take care of ensuring that the
|
||||||
" window-local override exists (and create one based on the global
|
" window-local override exists (and create one based on the global
|
||||||
" airline_section if not), and prepend to it.
|
" airline_section if not), and prepend to it.
|
||||||
call airline#extensions#prepend_to_section('x', g:airline_parts.cats)
|
call airline#extensions#prepend_to_section('x', airline#parts#get('cats').raw)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,6 @@ function! airline#extensions#hunks#get_hunks()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#hunks#init(ext)
|
function! airline#extensions#hunks#init(ext)
|
||||||
let g:airline_parts.hunks = '%{airline#extensions#hunks#get_hunks()}'
|
call airline#parts#define_function('hunks', 'airline#extensions#hunks#get_hunks')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,6 @@ function! airline#extensions#syntastic#get_warnings()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#syntastic#init(ext)
|
function! airline#extensions#syntastic#init(ext)
|
||||||
let g:airline_parts.syntastic = '%{airline#extensions#syntastic#get_warnings()}'
|
call airline#parts#define_function('syntastic', 'airline#extensions#syntastic#get_warnings')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,17 @@ function! airline#extensions#tagbar#inactive_apply(...)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! airline#extensions#tagbar#currenttag()
|
||||||
|
if get(w:, 'airline_active', 0)
|
||||||
|
return tagbar#currenttag('%s', '')
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#tagbar#init(ext)
|
function! airline#extensions#tagbar#init(ext)
|
||||||
call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply')
|
call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply')
|
||||||
let g:tagbar_status_func = 'airline#extensions#tagbar#get_status'
|
let g:tagbar_status_func = 'airline#extensions#tagbar#get_status'
|
||||||
|
|
||||||
let g:airline_parts.tagbar = '%(%{get(w:,"airline_active",0) ? tagbar#currenttag("%s","") : ""} '
|
call airline#parts#define_function('tagbar', 'airline#extensions#tagbar#currenttag')
|
||||||
\ .g:airline_right_alt_sep.' %)'
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ endfunction!
|
||||||
function! airline#extensions#whitespace#toggle()
|
function! airline#extensions#whitespace#toggle()
|
||||||
if s:enabled
|
if s:enabled
|
||||||
autocmd! airline_whitespace CursorHold,BufWritePost
|
autocmd! airline_whitespace CursorHold,BufWritePost
|
||||||
|
augroup! airline_whitespace
|
||||||
let s:enabled = 0
|
let s:enabled = 0
|
||||||
else
|
else
|
||||||
call airline#extensions#whitespace#init()
|
call airline#extensions#whitespace#init()
|
||||||
|
@ -65,7 +66,7 @@ function! airline#extensions#whitespace#toggle()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#whitespace#init(...)
|
function! airline#extensions#whitespace#init(...)
|
||||||
let g:airline_parts.whitespace = '%{airline#extensions#whitespace#check()}'
|
call airline#parts#define_function('whitespace', 'airline#extensions#whitespace#check')
|
||||||
|
|
||||||
unlet! b:airline_whitespace_check
|
unlet! b:airline_whitespace_check
|
||||||
augroup airline_whitespace
|
augroup airline_whitespace
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||||
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
|
function! s:check_defined(variable, default)
|
||||||
|
if !exists(a:variable)
|
||||||
|
let {a:variable} = a:default
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#init#bootstrap()
|
||||||
|
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
|
||||||
|
call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
|
||||||
|
call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<")
|
||||||
|
call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<")
|
||||||
|
call s:check_defined('g:airline_detect_modified', 1)
|
||||||
|
call s:check_defined('g:airline_detect_paste', 1)
|
||||||
|
call s:check_defined('g:airline_detect_iminsert', 0)
|
||||||
|
call s:check_defined('g:airline_inactive_collapse', 1)
|
||||||
|
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
|
||||||
|
call s:check_defined('g:airline_exclude_filetypes', [])
|
||||||
|
call s:check_defined('g:airline_exclude_preview', 0)
|
||||||
|
|
||||||
|
call s:check_defined('g:airline_mode_map', {})
|
||||||
|
call extend(g:airline_mode_map, {
|
||||||
|
\ '__' : '------',
|
||||||
|
\ 'n' : 'NORMAL',
|
||||||
|
\ 'i' : 'INSERT',
|
||||||
|
\ 'R' : 'REPLACE',
|
||||||
|
\ 'v' : 'VISUAL',
|
||||||
|
\ 'V' : 'V-LINE',
|
||||||
|
\ 'c' : 'COMMAND',
|
||||||
|
\ '' : 'V-BLOCK',
|
||||||
|
\ 's' : 'SELECT',
|
||||||
|
\ 'S' : 'S-LINE',
|
||||||
|
\ '' : 'S-BLOCK',
|
||||||
|
\ }, 'keep')
|
||||||
|
|
||||||
|
call s:check_defined('g:airline_theme_map', {})
|
||||||
|
call extend(g:airline_theme_map, {
|
||||||
|
\ 'Tomorrow.*': 'tomorrow',
|
||||||
|
\ 'mo[l|n]okai': 'molokai',
|
||||||
|
\ 'wombat.*': 'wombat',
|
||||||
|
\ '.*solarized.*': 'solarized',
|
||||||
|
\ }, 'keep')
|
||||||
|
|
||||||
|
call s:check_defined('g:airline_symbols', {})
|
||||||
|
call extend(g:airline_symbols, {
|
||||||
|
\ 'paste': get(g:, 'airline_paste_symbol', 'PASTE'),
|
||||||
|
\ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? '' : 'RO'),
|
||||||
|
\ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? '✹' : '!',
|
||||||
|
\ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ),
|
||||||
|
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''),
|
||||||
|
\ }, 'keep')
|
||||||
|
|
||||||
|
call airline#parts#define_function('mode', 'airline#parts#mode')
|
||||||
|
call airline#parts#define_function('iminsert', 'airline#parts#iminsert')
|
||||||
|
call airline#parts#define_function('paste', 'airline#parts#paste')
|
||||||
|
call airline#parts#define('readonly', {
|
||||||
|
\ 'function': 'airline#parts#readonly',
|
||||||
|
\ 'highlight': 'airline_file',
|
||||||
|
\ })
|
||||||
|
call airline#parts#define_raw('file', '%f%m')
|
||||||
|
call airline#parts#define_raw('ffenc', '%{printf("%s%s",&fenc,strlen(&ff)>0?"[".&ff."]":"")}')
|
||||||
|
|
||||||
|
call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic'])
|
||||||
|
|
||||||
|
call airline#extensions#load()
|
||||||
|
|
||||||
|
if !exists('g:airline_section_a')
|
||||||
|
let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'iminsert'])
|
||||||
|
endif
|
||||||
|
if !exists('g:airline_section_b')
|
||||||
|
let g:airline_section_b = airline#section#create(['hunks', 'branch'])
|
||||||
|
endif
|
||||||
|
if !exists('g:airline_section_c')
|
||||||
|
let g:airline_section_c = airline#section#create(['%<', 'file'])
|
||||||
|
endif
|
||||||
|
if !exists('g:airline_section_gutter')
|
||||||
|
let g:airline_section_gutter = airline#section#create([' ', 'readonly', '%='])
|
||||||
|
endif
|
||||||
|
if !exists('g:airline_section_x')
|
||||||
|
let g:airline_section_x = airline#section#create_right(['tagbar', '%{&filetype}'])
|
||||||
|
endif
|
||||||
|
if !exists('g:airline_section_y')
|
||||||
|
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_right(['%3p%% %{g:airline_symbols.linenr} %3l:%3c '])
|
||||||
|
endif
|
||||||
|
if !exists('g:airline_section_warning')
|
||||||
|
let g:airline_section_warning = airline#section#create(['syntastic', 'whitespace'])
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
|
@ -1,13 +1,46 @@
|
||||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
|
let s:parts = {}
|
||||||
|
|
||||||
|
function! airline#parts#define(key, config)
|
||||||
|
let s:parts[a:key] = get(s:parts, a:key, {})
|
||||||
|
call extend(s:parts[a:key], a:config)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#parts#define_function(key, name)
|
||||||
|
call airline#parts#define(a:key, { 'function': a:name })
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#parts#define_text(key, text)
|
||||||
|
call airline#parts#define(a:key, { 'text': a:text })
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#parts#define_raw(key, raw)
|
||||||
|
call airline#parts#define(a:key, { 'raw': a:raw })
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#parts#define_empty(keys)
|
||||||
|
for key in a:keys
|
||||||
|
call airline#parts#define_raw(key, '')
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#parts#get(key)
|
||||||
|
return get(s:parts, a:key, {})
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#parts#mode()
|
||||||
|
return get(w:, 'airline_current_mode', '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! airline#parts#paste()
|
function! airline#parts#paste()
|
||||||
return g:airline_detect_paste && &paste ? ' '.g:airline_symbols.paste : ''
|
return g:airline_detect_paste && &paste ? g:airline_symbols.paste : ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#parts#iminsert()
|
function! airline#parts#iminsert()
|
||||||
if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name')
|
if g:airline_detect_iminsert && &iminsert && exists('b:keymap_name')
|
||||||
return ' '.g:airline_left_alt_sep.' '.toupper(b:keymap_name)
|
return toupper(b:keymap_name)
|
||||||
endif
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||||
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
|
function! s:get_val(key, append)
|
||||||
|
let part = airline#parts#get(a:key)
|
||||||
|
|
||||||
|
let val = ''
|
||||||
|
if exists('part.highlight')
|
||||||
|
let val .= '%#'.(part.highlight).'#'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists('part.function')
|
||||||
|
let func = (part.function).'()'
|
||||||
|
elseif exists('part.text')
|
||||||
|
let func = '"'.(part.text).'"'
|
||||||
|
elseif exists('part.raw')
|
||||||
|
return val.(part.raw)
|
||||||
|
else
|
||||||
|
return a:key
|
||||||
|
endif
|
||||||
|
|
||||||
|
if a:append > 0
|
||||||
|
let val .= '%{airline#util#append('.func.')}'
|
||||||
|
elseif a:append < 0
|
||||||
|
let val .= '%{airline#util#prepend('.func.')}'
|
||||||
|
else
|
||||||
|
let val .= '%{'.func.'}'
|
||||||
|
endif
|
||||||
|
return val
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#section#create(parts)
|
||||||
|
return join(map(a:parts, 's:get_val(v:val, 0)'), '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#section#create_left(parts)
|
||||||
|
let _ = s:get_val(a:parts[0], 0)
|
||||||
|
for i in range(1, len(a:parts) - 1)
|
||||||
|
let _ .= s:get_val(a:parts[i], 1)
|
||||||
|
endfor
|
||||||
|
return _
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#section#create_right(parts)
|
||||||
|
let _ = ''
|
||||||
|
for i in range(0, len(a:parts) - 2)
|
||||||
|
let _ .= s:get_val(a:parts[i], -1)
|
||||||
|
endfor
|
||||||
|
let _ .= s:get_val(a:parts[-1], 0)
|
||||||
|
return _
|
||||||
|
endfunction
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
|
function! airline#util#append(text)
|
||||||
|
return empty(a:text) ? '' : ' '.g:airline_left_alt_sep.' '.a:text
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#util#prepend(text)
|
||||||
|
return empty(a:text) ? '' : a:text.' '.g:airline_right_alt_sep.' '
|
||||||
|
endfunction
|
||||||
|
|
||||||
if v:version >= 704
|
if v:version >= 704
|
||||||
function! airline#util#getwinvar(winnr, key, def)
|
function! airline#util#getwinvar(winnr, key, def)
|
||||||
return getwinvar(a:winnr, a:key, a:def)
|
return getwinvar(a:winnr, a:key, a:def)
|
||||||
|
|
|
@ -391,9 +391,6 @@ For contributions into the plugin, here are the following guidelines:
|
||||||
b. Configuration variables for the extension should reside in the
|
b. Configuration variables for the extension should reside in the
|
||||||
extension, e.g. `g:airline#extensions#foo_plugin#bar_variable`.
|
extension, e.g. `g:airline#extensions#foo_plugin#bar_variable`.
|
||||||
|
|
||||||
c. A value should be added to the `g:airline_parts` dictionary such that
|
|
||||||
the extension can be arbitrarily positioned.
|
|
||||||
|
|
||||||
See the source of |example.vim| for a working extension.
|
See the source of |example.vim| for a working extension.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
|
@ -8,86 +8,13 @@ let g:loaded_airline = 1
|
||||||
|
|
||||||
" autocmd VimEnter * call airline#deprecation#check()
|
" autocmd VimEnter * call airline#deprecation#check()
|
||||||
|
|
||||||
function! s:check_defined(variable, default)
|
|
||||||
if !exists(a:variable)
|
|
||||||
let {a:variable} = a:default
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
let s:airline_initialized = 0
|
let s:airline_initialized = 0
|
||||||
let s:airline_theme_defined = 0
|
let s:airline_theme_defined = 0
|
||||||
function! s:init()
|
function! s:init()
|
||||||
if !s:airline_initialized
|
if !s:airline_initialized
|
||||||
let s:airline_initialized = 1
|
let s:airline_initialized = 1
|
||||||
|
|
||||||
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
|
call airline#init#bootstrap()
|
||||||
call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":">")
|
|
||||||
call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<")
|
|
||||||
call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<")
|
|
||||||
call s:check_defined('g:airline_detect_modified', 1)
|
|
||||||
call s:check_defined('g:airline_detect_paste', 1)
|
|
||||||
call s:check_defined('g:airline_detect_iminsert', 0)
|
|
||||||
call s:check_defined('g:airline_inactive_collapse', 1)
|
|
||||||
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
|
|
||||||
call s:check_defined('g:airline_exclude_filetypes', [])
|
|
||||||
call s:check_defined('g:airline_exclude_preview', 0)
|
|
||||||
|
|
||||||
call s:check_defined('g:airline_symbols', {})
|
|
||||||
call extend(g:airline_symbols, {
|
|
||||||
\ 'paste': get(g:, 'airline_paste_symbol', g:airline_left_alt_sep.' PASTE'),
|
|
||||||
\ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? '' : 'RO'),
|
|
||||||
\ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? '✹' : '!',
|
|
||||||
\ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ),
|
|
||||||
\ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''),
|
|
||||||
\ }, 'keep')
|
|
||||||
|
|
||||||
call s:check_defined('g:airline_parts', {})
|
|
||||||
call extend(g:airline_parts, {
|
|
||||||
\ 'mode': '%{get(w:,"airline_current_mode","")}',
|
|
||||||
\ 'iminsert': '%{airline#parts#iminsert()}',
|
|
||||||
\ 'paste': '%{airline#parts#paste()}',
|
|
||||||
\ 'readonly': '%#airline_file#%{airline#parts#readonly()}',
|
|
||||||
\ 'ffenc': '%{printf("%s%s",&fenc,strlen(&ff)>0?"[".&ff."]":"")}',
|
|
||||||
\ 'file': '%f%m',
|
|
||||||
\ 'hunks': '',
|
|
||||||
\ 'branch': '',
|
|
||||||
\ 'tagbar': '',
|
|
||||||
\ 'syntastic': '',
|
|
||||||
\ 'whitespace': '',
|
|
||||||
\ }, 'keep')
|
|
||||||
|
|
||||||
call s:check_defined('g:airline_mode_map', {})
|
|
||||||
call extend(g:airline_mode_map, {
|
|
||||||
\ '__' : '------',
|
|
||||||
\ 'n' : 'NORMAL',
|
|
||||||
\ 'i' : 'INSERT',
|
|
||||||
\ 'R' : 'REPLACE',
|
|
||||||
\ 'v' : 'VISUAL',
|
|
||||||
\ 'V' : 'V-LINE',
|
|
||||||
\ 'c' : 'COMMAND',
|
|
||||||
\ '' : 'V-BLOCK',
|
|
||||||
\ 's' : 'SELECT',
|
|
||||||
\ 'S' : 'S-LINE',
|
|
||||||
\ '' : 'S-BLOCK',
|
|
||||||
\ }, 'keep')
|
|
||||||
|
|
||||||
call s:check_defined('g:airline_theme_map', {})
|
|
||||||
call extend(g:airline_theme_map, {
|
|
||||||
\ 'Tomorrow.*': 'tomorrow',
|
|
||||||
\ 'mo[l|n]okai': 'molokai',
|
|
||||||
\ 'wombat.*': 'wombat',
|
|
||||||
\ '.*solarized.*': 'solarized',
|
|
||||||
\ }, 'keep')
|
|
||||||
|
|
||||||
call airline#extensions#load()
|
|
||||||
call s:check_defined('g:airline_section_a', (g:airline_parts.mode).(g:airline_parts.paste).(g:airline_parts.iminsert))
|
|
||||||
call s:check_defined('g:airline_section_b', (g:airline_parts.hunks).(g:airline_parts.branch))
|
|
||||||
call s:check_defined('g:airline_section_c', '%<'.(g:airline_parts.file))
|
|
||||||
call s:check_defined('g:airline_section_gutter', ' '.(g:airline_parts.readonly).'%=')
|
|
||||||
call s:check_defined('g:airline_section_x', (g:airline_parts.tagbar).'%{&filetype}')
|
|
||||||
call s:check_defined('g:airline_section_y', g:airline_parts.ffenc)
|
|
||||||
call s:check_defined('g:airline_section_z', '%3p%% %{g:airline_symbols.linenr} %3l:%3c ')
|
|
||||||
call s:check_defined('g:airline_section_warning', (g:airline_parts.syntastic).(g:airline_parts.whitespace))
|
|
||||||
|
|
||||||
let s:airline_theme_defined = exists('g:airline_theme')
|
let s:airline_theme_defined = exists('g:airline_theme')
|
||||||
if s:airline_theme_defined || !airline#switch_matching_theme()
|
if s:airline_theme_defined || !airline#switch_matching_theme()
|
||||||
|
@ -127,47 +54,48 @@ function! s:airline_toggle()
|
||||||
au!
|
au!
|
||||||
augroup END
|
augroup END
|
||||||
augroup! airline
|
augroup! airline
|
||||||
if exists("s:stl")
|
|
||||||
let &stl = s:stl
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let s:stl = &stl
|
|
||||||
augroup airline
|
|
||||||
autocmd!
|
|
||||||
|
|
||||||
autocmd CmdwinEnter *
|
if exists("s:stl")
|
||||||
\ call airline#add_statusline_func('airline#cmdwinenter')
|
let &stl = s:stl
|
||||||
\ | call <sid>on_window_changed()
|
|
||||||
autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter')
|
|
||||||
|
|
||||||
autocmd ColorScheme * call <sid>on_colorscheme_changed()
|
|
||||||
autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost,VimResized *
|
|
||||||
\ call <sid>on_window_changed()
|
|
||||||
|
|
||||||
autocmd BufWritePost */autoload/airline/themes/*.vim
|
|
||||||
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
|
||||||
\ | call airline#load_theme()
|
|
||||||
augroup END
|
|
||||||
if s:airline_initialized
|
|
||||||
call <sid>on_window_changed()
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
else
|
||||||
|
let s:stl = &stl
|
||||||
|
augroup airline
|
||||||
|
autocmd!
|
||||||
|
|
||||||
function! s:get_airline_themes(a, l, p)
|
autocmd CmdwinEnter *
|
||||||
let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n")
|
\ call airline#add_statusline_func('airline#cmdwinenter')
|
||||||
return map(files, 'fnamemodify(v:val, ":t:r")')
|
\ | call <sid>on_window_changed()
|
||||||
endfunction
|
autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter')
|
||||||
function! s:airline_theme(...)
|
|
||||||
if a:0
|
autocmd ColorScheme * call <sid>on_colorscheme_changed()
|
||||||
call airline#switch_theme(a:1)
|
autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost,VimResized *
|
||||||
else
|
\ call <sid>on_window_changed()
|
||||||
echo g:airline_theme
|
|
||||||
|
autocmd BufWritePost */autoload/airline/themes/*.vim
|
||||||
|
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
||||||
|
\ | call airline#load_theme()
|
||||||
|
augroup END
|
||||||
|
if s:airline_initialized
|
||||||
|
call <sid>on_window_changed()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endif
|
||||||
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
endfunction
|
||||||
command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
|
||||||
command! AirlineToggle call <sid>airline_toggle()
|
|
||||||
|
|
||||||
call <sid>airline_toggle()
|
function! s:get_airline_themes(a, l, p)
|
||||||
|
let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n")
|
||||||
|
return map(files, 'fnamemodify(v:val, ":t:r")')
|
||||||
|
endfunction
|
||||||
|
function! s:airline_theme(...)
|
||||||
|
if a:0
|
||||||
|
call airline#switch_theme(a:1)
|
||||||
|
else
|
||||||
|
echo g:airline_theme
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
||||||
|
command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
||||||
|
command! AirlineToggle call <sid>airline_toggle()
|
||||||
|
|
||||||
|
call <sid>airline_toggle()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
|
describe 'active builder'
|
||||||
|
before
|
||||||
|
let s:builder = airline#builder#new({'active': 1})
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have a call to check mode'
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%{airline#check_mode()}'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should transition colors from one to the next'
|
||||||
|
call s:builder.add_section('Normal', 'hello')
|
||||||
|
call s:builder.add_section('NonText', 'world')
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%#Normal#hello%#Normal_to_NonText#>%#NonText#world'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should split left/right sections'
|
||||||
|
call s:builder.split()
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%='
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'after split, sections use the right separator'
|
||||||
|
call s:builder.split()
|
||||||
|
call s:builder.add_section('Normal', 'hello')
|
||||||
|
call s:builder.add_section('NonText', 'world')
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%#Normal#hello%#Normal_to_NonText#<%#NonText#world'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'inactive builder'
|
||||||
|
before
|
||||||
|
let s:builder = airline#builder#new({'active': 0})
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should transition colors from one to the next'
|
||||||
|
call s:builder.add_section('Normal', 'hello')
|
||||||
|
call s:builder.add_section('NonText', 'world')
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%#Normal_inactive#hello%#Normal_to_NonText_inactive#>%#NonText_inactive#world'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
source plugin/airline.vim
|
||||||
|
|
||||||
|
describe 'commands'
|
||||||
|
it 'should toggle off and on'
|
||||||
|
execute 'AirlineToggle'
|
||||||
|
Expect exists('#airline') to_be_false
|
||||||
|
execute 'AirlineToggle'
|
||||||
|
Expect exists('#airline') to_be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should toggle whitespace off and on'
|
||||||
|
execute 'AirlineToggleWhitespace'
|
||||||
|
Expect exists('#airline_whitespace') to_be_false
|
||||||
|
execute 'AirlineToggleWhitespace'
|
||||||
|
Expect exists('#airline_whitespace') to_be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should display theme name with no args'
|
||||||
|
execute 'AirlineTheme simple'
|
||||||
|
Expect g:airline_theme == 'simple'
|
||||||
|
execute 'AirlineTheme dark'
|
||||||
|
Expect g:airline_theme == 'dark'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
|
describe 'default'
|
||||||
|
before
|
||||||
|
let s:builder = airline#builder#new({'active': 1})
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should use the layout'
|
||||||
|
let g:airline#extensions#default#layout = [
|
||||||
|
\ [ 'c', 'a', 'b', 'warning' ],
|
||||||
|
\ [ 'x', 'z', 'y' ]
|
||||||
|
\ ]
|
||||||
|
call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 })
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ 'airline_c_to_airline_a'
|
||||||
|
Expect stl =~ 'airline_a_to_airline_b'
|
||||||
|
Expect stl =~ 'airline_b_to_airline_warning'
|
||||||
|
Expect stl =~ 'airline_x_to_airline_z'
|
||||||
|
Expect stl =~ 'airline_z_to_airline_y'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
let s:sections = ['a', 'b', 'c', 'gutter', 'x', 'y', 'z', 'warning']
|
||||||
|
|
||||||
|
function! s:clear()
|
||||||
|
for key in s:sections
|
||||||
|
unlet! g:airline_section_{key}
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
describe 'init'
|
||||||
|
before
|
||||||
|
call s:clear()
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
end
|
||||||
|
|
||||||
|
after
|
||||||
|
call s:clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'section a should have mode, paste, iminsert'
|
||||||
|
Expect g:airline_section_a =~ 'mode'
|
||||||
|
Expect g:airline_section_a =~ 'paste'
|
||||||
|
Expect g:airline_section_a =~ 'iminsert'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'section b should be blank because no extensions are installed'
|
||||||
|
Expect g:airline_section_b == ''
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'section c should be file'
|
||||||
|
Expect g:airline_section_c == '%<%f%m'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'section x should be filetype'
|
||||||
|
Expect g:airline_section_x =~ '&filetype'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'section y should be fenc and ff'
|
||||||
|
Expect g:airline_section_y =~ 'ff'
|
||||||
|
Expect g:airline_section_y =~ 'fenc'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'section z should be line numbers'
|
||||||
|
Expect g:airline_section_z =~ '%3p%%'
|
||||||
|
Expect g:airline_section_z =~ '%3l'
|
||||||
|
Expect g:airline_section_z =~ '%3c'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not redefine sections already defined'
|
||||||
|
for s in s:sections
|
||||||
|
let g:airline_section_{s} = s
|
||||||
|
endfor
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
for s in s:sections
|
||||||
|
Expect g:airline_section_{s} == s
|
||||||
|
endfor
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'all default statusline extensions should be blank'
|
||||||
|
Expect airline#parts#get('hunks').raw == ''
|
||||||
|
Expect airline#parts#get('branch').raw == ''
|
||||||
|
Expect airline#parts#get('tagbar').raw == ''
|
||||||
|
Expect airline#parts#get('syntastic').raw == ''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
describe 'parts'
|
||||||
|
it 'overwrites existing values'
|
||||||
|
call airline#parts#define('foo', { 'test': '123' })
|
||||||
|
Expect airline#parts#get('foo').test == '123'
|
||||||
|
call airline#parts#define('foo', { 'test': '321' })
|
||||||
|
Expect airline#parts#get('foo').test == '321'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'can define a function part'
|
||||||
|
call airline#parts#define_function('func', 'bar')
|
||||||
|
Expect airline#parts#get('func').function == 'bar'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'can define a text part'
|
||||||
|
call airline#parts#define_text('text', 'bar')
|
||||||
|
Expect airline#parts#get('text').text == 'bar'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'can define a raw part'
|
||||||
|
call airline#parts#define_raw('raw', 'bar')
|
||||||
|
Expect airline#parts#get('raw').raw == 'bar'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
|
function! SectionSpec()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
describe 'section'
|
||||||
|
before
|
||||||
|
call airline#parts#define_text('text', 'text')
|
||||||
|
call airline#parts#define_raw('raw', 'raw')
|
||||||
|
call airline#parts#define_function('func', 'SectionSpec')
|
||||||
|
call airline#parts#define('hi', {
|
||||||
|
\ 'raw': 'hello',
|
||||||
|
\ 'highlight': 'hlgroup',
|
||||||
|
\ })
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should create sections with no separators'
|
||||||
|
let s = airline#section#create(['text', 'raw', 'func'])
|
||||||
|
Expect s == '%{"text"}raw%{SectionSpec()}'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should create left sections with separators'
|
||||||
|
let s = airline#section#create_left(['text', 'text'])
|
||||||
|
Expect s == '%{"text"}%{airline#util#append("text")}'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should create right sections with separators'
|
||||||
|
let s = airline#section#create_right(['text', 'text'])
|
||||||
|
Expect s == '%{airline#util#prepend("text")}%{"text"}'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should prefix with highlight group if provided'
|
||||||
|
let s = airline#section#create(['hi'])
|
||||||
|
Expect s == '%#hlgroup#hello'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
|
function! Util1()
|
||||||
|
let g:count += 1
|
||||||
|
endfunction
|
||||||
|
function! Util2()
|
||||||
|
let g:count += 2
|
||||||
|
endfunction
|
||||||
|
function! Util3(...)
|
||||||
|
let g:count = a:0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
describe 'util'
|
||||||
|
before
|
||||||
|
let g:count = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has append wrapper function'
|
||||||
|
Expect airline#util#append('') == ''
|
||||||
|
Expect airline#util#append('1') == ' > 1'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has prepend wrapper function'
|
||||||
|
Expect airline#util#prepend('') == ''
|
||||||
|
Expect airline#util#prepend('1') == '1 < '
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has getwinvar function'
|
||||||
|
Expect airline#util#getwinvar(1, 'asdf', '123') == '123'
|
||||||
|
call setwinvar(1, 'vspec', 'is cool')
|
||||||
|
Expect airline#util#getwinvar(1, 'vspec', '') == 'is cool'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has exec funcrefs helper functions'
|
||||||
|
call airline#util#exec_funcrefs([function('Util1'), function('Util2')])
|
||||||
|
Expect g:count == 3
|
||||||
|
|
||||||
|
call airline#util#exec_funcrefs([function('Util3')], 1, 2, 3, 4)
|
||||||
|
Expect g:count == 4
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue