vim-airline/doc/airline.txt

794 lines
32 KiB
Plaintext
Raw Normal View History

2013-09-07 21:50:55 +08:00
*airline.txt* Lean and mean status/tabline that's light as air
2013-09-27 22:34:33 +08:00
*airline*
2013-08-11 07:22:42 +08:00
_ _ _ _ ~
__ _(_)_ __ ___ __ _(_)_ __| (_)_ __ ___ ~
\ \ / / | '_ ` _ \ _____ / _` | | '__| | | '_ \ / _ \ ~
\ V /| | | | | | |_____| (_| | | | | | | | | | __/ ~
\_/ |_|_| |_| |_| \__,_|_|_| |_|_|_| |_|\___| ~
~
2013-07-01 19:33:26 +08:00
==============================================================================
2013-09-27 22:34:33 +08:00
CONTENTS *airline-contents*
01. Intro ............................................... |airline-intro|
02. Features ......................................... |airline-features|
03. Name ................................................. |airline-name|
04. Configuration ............................... |airline-configuration|
05. Commands ......................................... |airline-commands|
06. Customization ............................... |airline-customization|
07. Extensions ..................................... |airline-extensions|
08. Advanced Customization ............. |airline-advanced-customization|
09. Funcrefs ......................................... |airline-funcrefs|
10. Pipeline ......................................... |airline-pipeline|
11. Writing Extensions ..................... |airline-writing-extensions|
12. Writing Themes ..................................... |airline-themes|
13. Troubleshooting ........................... |airline-troubleshooting|
14. Contributions ............................... |airline-contributions|
15. License ........................................... |airline-license|
==============================================================================
INTRODUCTION *airline-intro*
2013-07-01 19:33:26 +08:00
2013-08-02 20:11:53 +08:00
vim-airline is a fast and lightweight alternative to powerline, written
in 100% vimscript with no outside dependencies.
2013-07-01 19:33:26 +08:00
2013-08-02 20:11:53 +08:00
==============================================================================
FEATURES *airline-features*
* tiny core written with extensibility in mind.
* integrates with many popular plugins.
2013-08-01 04:07:14 +08:00
* looks good with regular fonts, and provides configuration points so you
can use unicode or powerline symbols.
* optimized for speed; it loads in under a millisecond.
* fully customizable; if you know a little 'statusline' syntax you can
tweak it to your needs.
2013-08-11 07:22:42 +08:00
* extremely easy to write themes.
2013-07-01 19:33:26 +08:00
==============================================================================
NAME *airline-name*
Where did the name come from?
2013-07-01 19:33:26 +08:00
I wrote this on an airplane, and since it's light as air it turned out to be a
2013-07-01 19:33:26 +08:00
good name :-)
==============================================================================
CONFIGURATION *airline-configuration*
2013-07-01 19:33:26 +08:00
There are a couple configuration values available (shown with their default
2013-07-01 19:33:26 +08:00
values):
* the separator used on the left side >
2013-07-01 19:33:26 +08:00
let g:airline_left_sep='>'
<
* the separator used on the right side >
2013-07-02 17:49:06 +08:00
let g:airline_right_sep='<'
2013-07-01 19:33:26 +08:00
<
* enable modified detection >
let g:airline_detect_modified=1
* enable paste detection >
let g:airline_detect_paste=1
<
* enable iminsert detection >
2013-08-27 11:07:14 +08:00
let g:airline_detect_iminsert=0
<
* determine whether inactive windows should have the left section collapsed to
only the filename of that buffer. >
let g:airline_inactive_collapse=1
<
* themes are automatically selected based on the matching colorscheme. this
can be overridden by defining a value. >
let g:airline_theme=
2013-07-01 19:33:26 +08:00
<
* if you want to patch the airline theme before it gets applied, you can
supply the name of a function where you can modify the palette. >
let g:airline_theme_patch_func = 'AirlineThemePatch'
function! AirlineThemePatch(palette)
if g:airline_theme == 'badwolf'
for colors in values(a:palette.inactive)
let colors[3] = 245
endfor
endif
endfunction
<
2013-09-08 02:33:47 +08:00
* enable/disable automatic population of the `g:airline_symbols` dictionary
with powerline symbols. >
2013-07-01 19:33:26 +08:00
let g:airline_powerline_fonts=0
<
* define the set of text to display for each mode. >
let g:airline_mode_map = {} " see source for the defaults
" or copy paste the following into your vimrc for shortform text
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'c' : 'C',
\ 'v' : 'V',
\ 'V' : 'V',
\ '' : 'V',
\ 's' : 'S',
\ 'S' : 'S',
\ '' : 'S',
\ }
<
2013-07-02 19:04:36 +08:00
* define the set of filename match queries which excludes a window from having
its statusline modified >
2013-07-02 19:04:36 +08:00
let g:airline_exclude_filenames = [] " see source for current list
<
* define the set of filetypes which are excluded from having its window
statusline modified >
let g:airline_exclude_filetypes = [] " see source for current list
<
* defines whether the preview window should be excluded from have its window
statusline modified (may help with plugins which use the preview window
heavily) >
let g:airline_exclude_preview = 0
<
==============================================================================
COMMANDS *airline-commands*
:AirlineTheme {theme-name} *:AirlineTheme*
Displays or changes the current theme.
2013-08-08 22:42:27 +08:00
:AirlineToggleWhitespace *:AirlineToggleWhitespace*
Toggles whitespace detection.
2013-08-15 05:56:55 +08:00
:AirlineToggle *:AirlineToggle*
2013-10-06 21:01:01 +08:00
Toggles between the standard 'statusline' and airline.
:AirlineRefresh *:AirlineRefresh*
Refreshes all highlight groups and redraws the statusline.
2013-08-15 05:56:55 +08:00
==============================================================================
CUSTOMIZATION *airline-customization*
The following are some unicode symbols for customizing the left/right
separators, as well as the powerline font glyths.
2013-09-15 21:22:23 +08:00
Note: You must define the dictionary first before setting values. Also, it's a
good idea to check whether if it exists as to avoid accidentally overwritting
its contents. >
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
2013-08-27 11:34:02 +08:00
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = '␤'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
" powerline symbols
let g:airline_left_sep = ''
2013-07-08 08:38:19 +08:00
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
2013-08-27 11:34:02 +08:00
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
" old vim-powerline symbols
let g:airline_left_sep = '⮀'
let g:airline_left_alt_sep = '⮁'
let g:airline_right_sep = '⮂'
let g:airline_right_alt_sep = '⮃'
2013-08-27 11:34:02 +08:00
let g:airline_symbols.branch = '⭠'
let g:airline_symbols.readonly = '⭤'
let g:airline_symbols.linenr = '⭡'
<
For more intricate customizations, you can replace the predefined sections
2013-08-24 11:02:13 +08:00
with the usual statusline syntax.
Note: If you define any section variables it will replace the default values
entirely. If you want to disable only certain parts of a section you can try
using variables defined in the |airline-configuration| or |airline-extensions|
section.
>
variable names default contents
----------------------------------------------------------------------------
2013-08-28 10:36:12 +08:00
let g:airline_section_a (mode, paste, iminsert)
let g:airline_section_b (hunks, branch)
let g:airline_section_c (bufferline or filename)
2013-08-21 07:27:55 +08:00
let g:airline_section_gutter (readonly, csv)
2013-08-28 10:36:12 +08:00
let g:airline_section_x (tagbar, filetype, virtualenv)
let g:airline_section_y (fileencoding, fileformat)
let g:airline_section_z (percentage, line number, column number)
2013-08-07 09:42:32 +08:00
let g:airline_section_warning (syntastic, whitespace)
" here is an example of how you could replace the branch indicator with
" the current working directory, followed by the filename.
let g:airline_section_b = '%{getcwd()}'
let g:airline_section_c = '%t'
<
==============================================================================
EXTENSIONS *airline-extensions*
2013-08-24 11:02:13 +08:00
Most extensions are enabled by default and lazily loaded when the
corresponding plugin (if any) is detected.
By default, airline will attempt to load any extension it can find in the
'runtimepath'. On some systems this can result in an undersirable startup
cost. You can disable the check with the following flag. >
let g:airline#extensions#disable_rtp_load = 1
<
Note: Third party plugins that rely on this behavior will be affected. You
will need to manually load them.
------------------------------------- *airline-default*
The default extension understands all of the `g:` variables in the
|airline-configuration| section, however it also has some more fine-tuned
configuration values that you can use.
* control which sections get truncated and at what width. >
let g:airline#extensions#default#section_truncate_width = {
\ 'b': 79,
2013-08-27 19:55:28 +08:00
\ 'x': 60,
\ 'y': 88,
\ 'z': 45,
2014-04-26 00:25:33 +08:00
\ }
" Note: set to an empty dictionary to disable truncation.
let g:airline#extensions#default#section_truncate_width = {}
<
* configure the layout of the sections by specificing an array of two arrays
(first array is the left side, second array is the right side). >
let g:airline#extensions#default#layout = [
\ [ 'a', 'b', 'c' ],
\ [ 'x', 'y', 'z', 'warning' ]
2014-04-26 00:25:33 +08:00
\ ]
<
------------------------------------- *airline-quickfix*
The quickfix extension is a simple built-in extension which determines
whether the buffer is a quickfix or location list buffer, and adjusts the
title accordingly.
* configure the title text for quickfix buffers >
let g:airline#extensions#quickfix#quickfix_text = 'Quickfix'
<
* configure the title text for location list buffers >
let g:airline#extensions#quickfix#location_text = 'Location'
<
------------------------------------- *airline-bufferline*
vim-bufferline <https://github.com/bling/vim-bufferline>
* enable/disable bufferline integration >
let g:airline#extensions#bufferline#enabled = 1
<
* determine whether bufferline will overwrite customization variables >
let g:airline#extensions#bufferline#overwrite_variables = 1
<
------------------------------------- *airline-branch*
fugitive.vim <https://github.com/tpope/vim-fugitive>
lawrencium <https://bitbucket.org/ludovicchabant/vim-lawrencium>
vcscommand <http://www.vim.org/scripts/script.php?script_id=90>
* enable/disable fugitive/lawrencium integration >
let g:airline#extensions#branch#enabled = 1
<
* change the text for when no branch is detected >
let g:airline#extensions#branch#empty_message = ''
* use vcscommand.vim if available >
let g:airline#extensions#branch#use_vcscommand = 0
2014-05-22 01:41:53 +08:00
* truncate long branch names to a fixed length >
let g:airline#extensions#branch#displayed_head_limit = 10
------------------------------------- *airline-syntastic*
syntastic <https://github.com/scrooloose/syntastic>
* enable/disable syntastic integration >
let g:airline#extensions#syntastic#enabled = 1
<
------------------------------------- *airline-tagbar*
tagbar <https://github.com/majutsushi/tagbar>
* enable/disable tagbar integration >
let g:airline#extensions#tagbar#enabled = 1
<
* change how tags are displayed (:help tagbar-statusline) >
let g:airline#extensions#tagbar#flags = '' (default)
let g:airline#extensions#tagbar#flags = 'f'
2013-09-05 23:21:04 +08:00
let g:airline#extensions#tagbar#flags = 's'
let g:airline#extensions#tagbar#flags = 'p'
<
------------------------------------- *airline-csv*
csv.vim <https://github.com/chrisbra/csv.vim>
2013-08-19 05:02:33 +08:00
* enable/disable csv integration for displaying the current column. >
let g:airline#extensions#csv#enabled = 1
2013-08-19 05:02:33 +08:00
<
2013-08-14 10:36:09 +08:00
* change how columns are displayed. >
let g:airline#extensions#csv#column_display = 'Number' (default)
let g:airline#extensions#csv#column_display = 'Name'
2013-08-19 05:02:33 +08:00
<
------------------------------------- *airline-hunks*
2013-08-19 05:02:33 +08:00
vim-gitgutter <https://github.com/airblade/vim-gitgutter>
2013-08-20 23:43:26 +08:00
vim-signify <https://github.com/mhinz/vim-signify>
changesPlugin <https://github.com/chrisbra/changesPlugin>
2013-08-19 05:02:33 +08:00
2013-09-03 11:20:21 +08:00
* enable/disable showing a summary of changed hunks under source control. >
let g:airline#extensions#hunks#enabled = 1
<
* enable/disable showing only non-zero hunks. >
let g:airline#extensions#hunks#non_zero_only = 0
<
* set hunk count symbols. >
let g:airline#extensions#hunks#hunk_symbols = ['+', '~', '-']
<
2013-09-03 11:20:21 +08:00
------------------------------------- *airline-ctrlp*
ctrlp <https://github.com/kien/ctrlp.vim>
* configure which mode colors should ctrlp window use (takes effect
only if the active airline theme doesn't define ctrlp colors) >
let g:airline#extensions#ctrlp#color_template = 'insert' (default)
let g:airline#extensions#ctrlp#color_template = 'normal'
let g:airline#extensions#ctrlp#color_template = 'visual'
let g:airline#extensions#ctrlp#color_template = 'replace'
<
* configure whether to show the previous and next modes (mru, buffer, etc...)
>
let g:airline#extensions#ctrlp#show_adjacent_modes = 1
<
2013-09-03 11:20:21 +08:00
------------------------------------- *airline-virtualenv*
virtualenv <https://github.com/jmcantrell/vim-virtualenv>
* enable/disable virtualenv integration >
let g:airline#extensions#virtualenv#enabled = 1
<
------------------------------------- *airline-eclim*
eclim <https://eclim.org>
* enable/disable eclim integration, which works well with the
|airline-syntastic| extension. >
let g:airline#extensions#eclim#enabled = 1
------------------------------------- *airline-whitespace*
2013-08-20 08:35:48 +08:00
* enable/disable detection of whitespace errors. >
let g:airline#extensions#whitespace#enabled = 1
<
* customize the type of mixed indent checking to perform. >
" must be all spaces or all tabs before the first non-whitespace character
let g:airline#extensions#whitespace#mixed_indent_algo = 0 (default)
" certain number of spaces are allowed after tabs, but not in between
" this algorithm works well for /** */ style comments in a tab-indented file
let g:airline#extensions#whitespace#mixed_indent_algo = 1
<
2013-08-20 08:35:48 +08:00
* customize the whitespace symbol. >
let g:airline#extensions#whitespace#symbol = '!'
<
* configure which whitespace checks to enable. >
let g:airline#extensions#whitespace#checks = [ 'indent', 'trailing' ]
<
* configure the maximum number of lines where whitespace checking is enabled. >
let g:airline#extensions#whitespace#max_lines = 20000
<
2013-08-20 08:35:48 +08:00
* configure whether a message should be displayed. >
let g:airline#extensions#whitespace#show_message = 1
<
* configure the formatting of the warning messages. >
let g:airline#extensions#whitespace#trailing_format = 'trailing[%s]'
let g:airline#extensions#whitespace#mixed_indent_format = 'mixed-indent[%s]'
2013-08-20 08:35:48 +08:00
<
2013-09-03 11:20:21 +08:00
------------------------------------- *airline-tabline*
* enable/disable enhanced tabline. >
let g:airline#extensions#tabline#enabled = 0
<
* enable/disable displaying buffers with a single tab. >
let g:airline#extensions#tabline#show_buffers = 1
<
2013-09-03 11:20:21 +08:00
* configure filename match rules to exclude from the tabline. >
let g:airline#extensions#tabline#excludes = []
<
* configure how numbers are calculated in tab mode. >
let g:airline#extensions#tabline#tab_nr_type = 0 " # of splits (default)
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
<
* enable/disable displaying tab number in tabs mode. >
let g:airline#extensions#tabline#show_tab_nr = 1
* enable/disable displaying tab type (far right)
let g:airline#extensions#tabline#show_tab_type = 1
* enable/disable displaying index of the buffer.
When enabled, numbers will be displayed in the tabline and mappings will be
exposed to allow you to select a buffer directly. Up to 9 mappings will be
exposed.
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
Note: Mappings will be ignored within a NERDTree buffer.
* defines the name of a formatter for how buffer names are displayed. >
let g:airline#extensions#tabline#formatter = 'default'
" here is how you can define a 'foo' formatter:
function! airline#extensions#tabline#foo#format(bufnr, buffers)
return fnamemodify(bufname(a:bufnr), ':t')
endfunction
let g:airline#extensions#tabline#formatter = 'foo'
<
2013-09-07 09:52:53 +08:00
Note: the following variables are only used by the 'default' formatter.
2013-09-07 09:52:53 +08:00
* configure whether buffer numbers should be shown. >
let g:airline#extensions#tabline#buffer_nr_show = 0
<
2013-09-07 09:52:53 +08:00
* configure how buffer numbers should be formatted with |printf|. >
let g:airline#extensions#tabline#buffer_nr_format = '%s: '
<
* configure the formatting of filenames (see |filename-modifiers|). >
let g:airline#extensions#tabline#fnamemod = ':p:.'
<
* configure collapsing parent directories in buffer name. >
let g:airline#extensions#tabline#fnamecollapse = 1
" The `unique_tail` algorithm will display the tail of the filename, unless
" there is another file of the same name, in which it will display it along
" with the containing parent directory.
let g:airline#extensions#tabline#formatter = 'unique_tail'
2013-12-26 14:16:30 +08:00
" The `unique_tail_improved` - another algorithm, that will smartly uniquify
2013-12-23 13:58:24 +08:00
" buffers names with similar filename, suppressing common parts of paths.
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
<
* configure the minimum number of buffers needed to show the tabline. >
let g:airline#extensions#tabline#buffer_min_count = 0
<
Note: this setting only applies to a single tab and when `show_buffers` is
true.
* configure the minimum number of tabs needed to show the tabline. >
let g:airline#extensions#tabline#tab_min_count = 0
<
Note: this setting only applies when `show_buffers` is false.
2013-09-07 21:50:55 +08:00
* configure separators for the tabline only. >
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
let g:airline#extensions#tabline#right_sep = ''
let g:airline#extensions#tabline#right_alt_sep = ''
2014-09-04 06:48:48 +08:00
* configure whether close button should be shown
let g:airline#extensions#tabline#show_close_button = 1
* configure symbol used to represent close button
let g:airline#extensions#tabline#close_symbol = 'X'
<
Note: Enabling this extension will modify 'showtabline' and 'guioptions'.
2014-01-06 01:47:44 +08:00
------------------------------------- *airline-tmuxline*
2013-11-18 03:15:55 +08:00
tmuxline <https://github.com/edkolev/tmuxline.vim>
* enable/disable tmuxline integration >
let g:airline#extensions#tmuxline#enabled = 0
<
* configure which mode colors should be used in tmux statusline >
let airline#extensions#tmuxline#color_template = 'normal' (default)
let airline#extensions#tmuxline#color_template = 'insert'
let airline#extensions#tmuxline#color_template = 'visual'
let airline#extensions#tmuxline#color_template = 'replace'
<
* if specified, setting this option will trigger writing to the file whenever the
airline theme is applied, i.e. when :AirlineTheme is executed and on vim
startup >
airline#extensions#tmuxline#snapshot_file = "~/.tmux-statusline-colors.conf"
<
2014-01-06 01:47:44 +08:00
------------------------------------- *airline-promptline*
promptline <https://github.com/edkolev/promptline.vim>
* configure the path to the snapshot .sh file. Mandatory option. The created
file should be sourced by the shell on login >
" in .vimrc
airline#extensions#promptline#snapshot_file = "~/.shell_prompt.sh"
" in .bashrc/.zshrc
[ -f ~/.shell_prompt.sh ] && source ~/.shell_prompt.sh
<
* enable/disable promptline integration >
let g:airline#extensions#promptline#enabled = 0
<
* configure which mode colors should be used in prompt >
let airline#extensions#promptline#color_template = 'normal' (default)
let airline#extensions#promptline#color_template = 'insert'
let airline#extensions#promptline#color_template = 'visual'
let airline#extensions#promptline#color_template = 'replace'
<
2014-04-23 06:13:16 +08:00
------------------------------------- *airline-nrrwrgn*
NrrwRgn <https://github.com/chrisbra/NrrwRgn>
* enable/disable NrrwRgn integration >
let g:airline#extensions#nrrwrgn#enabled = 1
2013-11-18 03:15:55 +08:00
2014-07-29 05:56:08 +08:00
------------------------------------- *airline-capslock*
vim-capslock <https://github.com/tpope/vim-capslock>
* enable/disable vim-capslock integration >
let g:airline#extensions#capslock#enabled = 1
2014-09-05 11:02:19 +08:00
------------------------------------- *airline-windowswap*
vim-windowswap <https://github.com/wesQ3/vim-windowswap>
* enable/disable vim-windowswap integration >
let g:airline#extensions#windowswap#enabled = 1
* set marked window indicator string >
let g:airline#extensions#windowswap#indicator_text = 'WS'
2014-07-29 05:56:08 +08:00
<
==============================================================================
ADVANCED CUSTOMIZATION *airline-advanced-customization*
The defaults will accomodate the mass majority of users with minimal
configuration. However, if you want to reposition sections or contents you can
2013-09-02 02:36:20 +08:00
do so with built-in helper functions, which makes it possible to create
sections in a more declarative style.
------------------------------------- *airline-parts*
A part is something that contains metadata that eventually gets rendered into
the statusline. You can define parts that contain constant strings or
functions. Defining parts is needed if you want to use features like automatic
insertion of separators or hiding based on window width.
For example, this is how you would define a part function: >
call airline#parts#define_function('foo', 'GetFooText')
<
2013-09-02 02:36:20 +08:00
Here is how you would define a part that is visible only if the window width
greater than a minimum width. >
call airline#parts#define_minwidth('foo', 50)
<
Parts can be configured to be visible conditionally. >
call airline#parts#define_condition('foo', 'getcwd() =~ "work_dir"')
<
2013-09-02 02:36:20 +08:00
Note: Part definitions are combinative; e.g. the two examples above modify the
same `foo` part.
Note: Look at the source code and tests for the full API.
------------------------------------- *airline-predefined-parts*
Before is a list of parts that are predefined by vim-airline.
* `mode` displays the current mode
* `iminsert` displays the current insert method
* `paste` displays the paste indicator
* `filetype` displays the file type
* `readonly` displays the read only indicator
* `file` displays the filename and modified indicator
* `ffenc` displays the file format and encoding
And the following are defined for their respective extensions:
`hunks`, `branch`, `tagbar`, `syntastic`, `whitespace`
------------------------------------- *airline-accents*
Accents can be defined on any part, like so: >
call airline#parts#define_accent('foo', 'red')
<
This will override the colors of that part by using what is defined in that
particular accent. In the above example, the `red` accent is used, which means
regardless of which section the part is used in, it will have red foreground
colors instead of the section's default foreground color.
The following accents are defined by default. Themes can define their variants
of the colors, but defaults will be provided if missing. >
bold, italic, red, green, blue, yellow, orange, purple
<
The defaults configure the mode and line number parts to be bold, and the
readonly part to be red.
2013-09-02 02:36:20 +08:00
------------------------------------- *airline-sections*
Once a part is defined, you can use helper functions to generate the
statuslines for each section. For example, to use the part above, we could
define a section like this: >
function! AirlineInit()
let g:airline_section_a = airline#section#create(['mode', ' ', 'foo'])
let g:airline_section_b = airline#section#create_left(['ffenc','file'])
2013-09-07 21:50:55 +08:00
let g:airline_section_c = airline#section#create(['%{getcwd()}'])
endfunction
autocmd VimEnter * call AirlineInit()
<
This will create a section with the `mode`, followed by a space, and our `foo`
part in section `a`. Section `b` will have two parts with a left-side
2013-09-08 02:33:47 +08:00
separator. And section `c` will contain the current path. You may notice that
the space and cwd are not defined parts. For convenience, if a part of that
key does not exist, it will be inserted as is. The unit tests will be a good
resource for possibilities.
Note: The use of |VimEnter| is important, because most extensions are lazily
loaded, so we must give them a chance to define their parts before we can use
them.
Note: The `airline#section#create` function and friends will do its best to
create a section with the appropriate separators, but it only works for
function and text parts. Special 'statusline' items like %f or raw/undefined
2013-09-08 02:33:47 +08:00
parts will not work as it is not possible to inspect their widths/contents
before rendering to the statusline.
==============================================================================
FUNCREFS *airline-funcrefs*
vim-airline internally uses funcrefs to integrate with third party plugins,
and you can tap into this functionality to extend it for you needs. This is
the most powerful way to customize the statusline, and sometimes it may be
easier to go this route than the above methods.
Every section can have two values. The default value is the global `g:`
variable which is used in the absense of a `w:` value. This makes it very easy
to override only certain parts of the statusline by only defining window-local
variables for a subset of all sections.
------------------------------------- *add_statusline_func*
The following is an example of how you can extend vim-airline to support a
new plugin. >
function! MyPlugin(...)
if &filetype == 'MyPluginFileType'
let w:airline_section_a = 'MyPlugin'
let w:airline_section_b = '%f'
let w:airline_section_c = '%{MyPlugin#function()}'
let g:airline_variable_referenced_in_statusline = 'foo'
endif
endfunction
call airline#add_statusline_func('MyPlugin')
<
2013-09-07 21:50:55 +08:00
Notice that only the left side of the statusline is overwritten. This means
the right side (the line/column numbers, etc) will be intact.
------------------------------------- *remove_statusline_func*
2013-08-24 11:02:13 +08:00
You can also remove a function as well, which is useful for when you want a
temporary override. >
call airline#remove_statusline_func('MyPlugin')
<
2013-08-23 07:20:53 +08:00
==============================================================================
PIPELINE *airline-pipeline*
2013-08-23 07:20:53 +08:00
Sometimes you want to do more than just use overrides. The statusline funcref
2013-08-28 10:36:12 +08:00
is invoked and passed two arguments. The first of these arguments is the
statusline builder. You can use this to build completely custom statuslines
to your liking. Here is an example: >
>
function! MyPlugin(...)
2013-08-23 07:20:53 +08:00
" first variable is the statusline builder
let builder = a:1
" WARNING: the API for the builder is not finalized and may change
call builder.add_section('Normal', '%f')
call builder.add_section('WarningMsg', '%{getcwd()}')
2013-08-28 10:36:12 +08:00
call builder.split()
call builder.add_section('airline_z', '%p%%')
2013-08-23 07:20:53 +08:00
2013-08-28 10:36:12 +08:00
" tell the core to use the contents of the builder
return 1
endfunction
<
2014-02-20 07:30:56 +08:00
The above example uses various example highlight groups to demonstrate
2013-09-07 21:50:55 +08:00
that you can use any combination from the loaded colorscheme. However, if
2013-08-28 10:36:12 +08:00
you want colors to change between modes, you should use one of the section
highlight groups, e.g. `airline_a` and `airline_b`.
2013-08-24 11:18:43 +08:00
The second variable is the context, which is a dictionary containing various
values such as whether the statusline is active or not, and the window number.
>
context = {
'winnr': 'the window number for the statusline',
'active': 'whether the window is active or not',
2013-09-07 21:50:55 +08:00
'bufnr': 'the current buffer for this window',
}
<
------------------------------------- *airline-pipeline-return-codes*
2013-08-24 11:02:13 +08:00
The pipeline accepts various return codes and can be used to determine the
next action. The following are the supported codes: >
0 the default, continue on with the next funcref
-1 do not modify the statusline
1 modify the statusline with the current contents of the builder
<
Note: Any value other than 0 will halt the pipeline and prevent the next
funcref from executing.
==============================================================================
WRITING EXTENSIONS *airline-writing-extensions*
For contributions into the plugin, here are the following guidelines:
1. For simple 'filetype' checks, they can be added directly into the
`extensions.vim` file.
2. Pretty much everything else should live as a separate file under the
`extensions/` directory.
a. Inside `extensions.vim`, add a check for some variable or command that
is always available (these must be defined in `plugin/`, and _not_
`autoload/` of the other plugin). If it exists, then initialize the
extension. This ensures that the extension is loaded if and only if the
2013-08-21 07:27:55 +08:00
user has the other plugin installed. Also, a check to
`airline#extensions#foo_plugin#enabled` should be performed to allow the
user to disable it.
2013-08-21 07:27:55 +08:00
b. Configuration variables for the extension should reside in the
extension, e.g. `g:airline#extensions#foo_plugin#bar_variable`.
2013-09-07 21:50:55 +08:00
See the source of |example.vim| for documented code of how to write one.
Looking at the other extensions is also a good resource.
2013-08-17 02:04:03 +08:00
==============================================================================
WRITING THEMES *airline-themes*
Themes are written "close to the metal" -- you will need to know some basic
VimL syntax to write a theme, but if you've written in any programming
language before it will be easy to pick up.
The |dark.vim| theme fully documents this procedure and will guide you through
the process. The |jellybeans.vim| theme is another example of how to write a
theme, but instead of manually declaring colors, it extracts the values from
highlight groups.
==============================================================================
TROUBLESHOOTING *airline-troubleshooting*
Q. There are no colors.
A. You need to set up your terminal correctly. For more details, see
2013-08-11 07:22:42 +08:00
<http://vim.wikia.com/wiki/256_colors_in_vim>. Alternatively, if you want
to bypass the automatic detection of terminal colors, you can force Vim
into 256 color mode with this: >
set t_Co=256
<
Q. The statusline does not appear until I create a split.
A. This is the default setting of 'laststatus'. If you want it to appear all
the time, add the following to your vimrc: >
set laststatus=2
<
Q. Powerline symbols are not showing up.
A. First, you must install patched powerline fonts. Second, you must enable
unicode in vim. >
set encoding=utf-8
<
Q. There is a pause when leaving insert mode.
A. Add the following to your vimrc. >
set ttimeoutlen=50
<
2013-08-11 07:22:42 +08:00
Q. The colors look a little off for some themes.
A. Certain themes are derived from the active colorscheme by extracting colors
from predefined highlight groups. These airline themes will look good for
their intended matching colorschemes, but will be hit or miss when loaded
with other colorschemes.
Solutions to other common problems can be found in the Wiki:
<https://github.com/bling/vim-airline/wiki/FAQ>
2013-07-01 19:33:26 +08:00
==============================================================================
CONTRIBUTIONS *airline-contributions*
2013-07-15 22:45:47 +08:00
Contributions and pull requests are welcome.
2013-07-01 19:33:26 +08:00
==============================================================================
LICENSE *airline-license*
2014-01-20 12:44:44 +08:00
MIT License. Copyright © 2013-2014 Bailey Ling.
2013-07-15 22:45:47 +08:00
2013-07-01 19:33:26 +08:00
vim:tw=78:ts=8:ft=help:norl: