From bc03ab5cbf7d049536b6f6f43cc92ff3003ed2f1 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 27 Aug 2013 01:12:00 +0000 Subject: [PATCH] support section truncation based on window width. resolves #190. --- README.md | 7 +++---- autoload/airline/extensions/default.vim | 10 ++++++++++ doc/airline.txt | 11 +++++++++++ plugin/airline.vim | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 28a6273a..d3d50614 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ Completely transform the statusline to your liking. ![allyourbase](https://f.cloud.github.com/assets/306502/1022714/e150034a-0da7-11e3-94a5-ca9d58a297e8.png) -# Integration with external plugins +# Seamless integration -vim-airline provides seamless integration with a variety of plugins. These extensions will be lazily loaded if and only if you have the other plugins installed (and of course you can turn them off if you don't like it). +vim-airline integrates with a variety of plugins out of the box. These extensions will be lazily loaded if and only if you have the other plugins installed (and of course you can turn them off). ### [ctrlp.vim][10] ![image](https://f.cloud.github.com/assets/306502/962258/7345a224-04ec-11e3-8b5a-f11724a47437.png) @@ -61,8 +61,7 @@ There's already [powerline][2], why yet another statusline? What about [vim-powerline][1]? -* the author has been active developing powerline, which was rewritten in python and expands its capabilities to tools outside of Vim, such as bash, zsh, and tmux. -* vim-powerline has been deprecated as a result, and no features will be added to it. +* vim-powerline has been deprecated in favor of the newer, undifying powerline, which is under active development; the new version is written in python and expands its capabilities to tools outside of vim, such as bash, zsh, and tmux. * vim-powerline uses different font codes, so if you want to use it with a powerline themed tmux (for example), it will not work. # Where did the name come from? diff --git a/autoload/airline/extensions/default.vim b/autoload/airline/extensions/default.vim index 8d6b7ff8..7cd8f876 100644 --- a/autoload/airline/extensions/default.vim +++ b/autoload/airline/extensions/default.vim @@ -1,7 +1,17 @@ " MIT License. Copyright (c) 2013 Bailey Ling. " vim: et ts=2 sts=2 sw=2 +let s:section_truncate_width = get(g:, 'airline#extensions#default#section_truncate_width', { + \ 'b': 90, + \ 'y': 90, + \ }) + function! s:get_section(winnr, key, ...) + if has_key(s:section_truncate_width, a:key) + if winwidth(a:winnr) < s:section_truncate_width[a:key] + return '' + endif + endif let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) let [prefix, suffix] = [get(a:000, 0, '%( '), get(a:000, 1, ' %)')] return empty(text) ? '' : prefix.text.suffix diff --git a/doc/airline.txt b/doc/airline.txt index 51c193d7..ed8d696b 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -185,6 +185,17 @@ EXTENSIONS *airline-extensions* Most extensions are enabled by default and lazily loaded when the corresponding plugin (if any) is detected. + *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': 90, + \ 'y': 90, + \ }) +< *airline-branch* fugitive.vim lawrencium diff --git a/plugin/airline.vim b/plugin/airline.vim index 2a520055..6c37b213 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -118,7 +118,7 @@ function! s:airline_toggle() autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter') autocmd ColorScheme * call on_colorscheme_changed() - autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost * + autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost,VimResized * \ call on_window_changed() autocmd BufWritePost */autoload/airline/themes/*.vim