localcfg/plugins/vim_airline.vim

Don’t limit ourselves to plain ASCII encoding:

scriptencoding utf-8

Enforce vim script implementation to reduce ambiguities and improve robustness:

scriptversion 4
powerlineish theme screenshot

Attempt to cache highlighting group changes:

const g:airline_highlighting_cache = v:true

Configure look:

let g:airline_theme = 'powerlineish'
const g:airline_skip_empty_sections = v:true
const g:airline_inactive_collapse = v:false

Requires Font Awesome in places.

Attention

I have Font Awesome available locally as webfonts are disabled in my browsers, if you don’t have a similar setup then the following won’t work.

Configure prettier symbols:

if index(split(&guifont), 'NF') != -1
    const g:airline_powerline_fonts = v:true
    const g:airline_left_sep = ''
    const g:airline_right_sep = ''
else
    const g:airline_left_sep = '╗'
    const g:airline_right_sep = '╔'
endif

if !exists('g:airline_symbols')
    let g:airline_symbols = {}
endif

let g:airline_symbols = #{
\   branch: '',
\   colnr: '℅',
\   crypt: '',
\   linenr: '',
\   maxlinenr: '⌇',
\   modified: '+',
\   notexists: 'Ɇ',
\   paste: 'ρ',
\   readonly: '',
\   space: ' ',
\   spell: '',
\   whitespace: 'Ξ',
\ }

Warning

'guifont' is normally only available with gvim, but we have a hacky workaround for regular vim.

Note

The NF-suffixed branch is here to prefer a nerd-fonts variation of a font if available.

Note

While I’d prefer to use fancy symbols in a terminal, too many terminals fail to correctly handle choosing an appropriate font for a given glyph.

Only show unusual encodings:

const g:airline#parts#ffenc#skip_expected_string = 'utf-8[unix]'

Only use the extensions I actually want:

const g:airline#extensions#disable_rtp_load = v:true
let g:airline_extensions = [
\   'csv',
\   'nrrwrgn',
\   'obsession',
\   'searchcount',
\   'tabline',
\   'unicode',
\   'vimagit',
\   'whitespace',
\   'wordcount',
\   'zoomwintab'
\ ]

Attention

This requires some vigilance over updates for finding fancy new toys, but surely you’re not just blinding grabbing repositories from GitHub anyway…

Show emoji flags instead of textual code for spelling language:

let g:airline_detect_spelllang = 'flag'

Warning

Support for variable width Unicode characters as used in the flag display is hugely dependent on both terminal support and the system’s font configuration. This will cause problems, but I’m of the the opinion that they’re worth fixing for their usability improvements.

The searchcount extension only displays its segment when 'hlsearch' is enabled, so we’ll fall back on 'shortmess'’s search counting functionality when it is disabled:

augroup jnrowe_vim_airline
    autocmd!
    autocmd OptionSet hlsearch call plugins#vim_airline#toggle_searchcount()
augroup END

Enable ale extension:

if has('signs')
    let g:airline_extensions += ['ale']
    const g:airline#extensions#ale#error_symbol = ''
    const g:airline#extensions#ale#warning_symbol = ''
    const g:airline#extensions#ale#checking_symbol = '…'
endif

Use simple statusline for quickfix windows:

if has('quickfix')
    let g:airline_extensions += ['quickfix']
endif

Enable git extension, if possible:

if executable('git')
    let g:airline_extensions += ['branch', 'hunks']

… truncate all but the basename-equivalent of branch names:

const g:airline#extensions#branch#format = 2

… use nice symbols:

const g:airline#extensions#hunks#hunk_symbols = ['➕ ', ' ', '➖ ']

… don’t display symbol and count when there are no changes:

const g:airline#extensions#hunks#non_zero_only = v:true
endif

Only show tabline when there are multiple buffers:

const g:airline#extensions#tabline#buffer_min_count = 2

Show buffer number for quicker switching:

const g:airline#extensions#tabline#buffer_nr_show = v:true

Prettier overflow:

const g:airline#extensions#tabline#overflow_marker = '…'

Make the rounded separators display correctly in the tabline:

const g:airline#extensions#tabline#alt_sep = v:true
const g:airline#extensions#tabline#left_alt_sep = ''

Use unique names for buffers in tabline:

const g:airline#extensions#tabline#formatter = 'unique_tail_improved'

Show simple reading time estimate:

const g:airline#extensions#wordcount#formatter = 'readingtime'

When CSV files have a header, use it:

const g:airline#extensions#csv#column_display = 'Name'

Note

The csv extension uses the excellent csv.vim plugin by Christian Brabandt.

Use a pretty symbol for vim-obsession:

const g:airline#extensions#obsession#indicator_text = ''

Allow spaces after tabs, but not in between:

const g:airline#extensions#whitespace#mixed_indent_algo = 2