From a7534225493ebcbbb28fa126967ce5fc37b0630d Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 26 Apr 2019 10:16:40 +0200 Subject: [PATCH] main: Make :AirlineRefresh! skip recrecrating highlighting groups When `g:skip_empty_sections` is set, `:AirlineRefresh` can be called very often and cause slow down, because it forcefully re-creates the highlighting groups. This is mostly not needed for the redraw to happen, therefore, add the `` attribute to the command, making it skip to re-create the highlighting groups and have all extensions that rely on a forced update use the `!` form. Should be much fast then. fixes #1908 --- autoload/airline/extensions/ale.vim | 2 +- autoload/airline/extensions/languageclient.vim | 2 +- autoload/airline/extensions/whitespace.vim | 2 +- doc/airline.txt | 5 +++-- plugin/airline.vim | 10 +++++++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/autoload/airline/extensions/ale.vim b/autoload/airline/extensions/ale.vim index d6f51b11..2816b2f6 100644 --- a/autoload/airline/extensions/ale.vim +++ b/autoload/airline/extensions/ale.vim @@ -124,6 +124,6 @@ endfunction function! s:ale_refresh() if get(g:, 'airline_skip_empty_sections', 0) - exe ':AirlineRefresh' + exe ':AirlineRefresh!' endif endfunction diff --git a/autoload/airline/extensions/languageclient.vim b/autoload/airline/extensions/languageclient.vim index f3b0e90a..aec88dda 100644 --- a/autoload/airline/extensions/languageclient.vim +++ b/autoload/airline/extensions/languageclient.vim @@ -22,7 +22,7 @@ let s:diagnostics = {} function! s:languageclient_refresh() if get(g:, 'airline_skip_empty_sections', 0) - exe ':AirlineRefresh' + exe ':AirlineRefresh!' endif endfunction diff --git a/autoload/airline/extensions/whitespace.vim b/autoload/airline/extensions/whitespace.vim index 29c03b6f..23916cbd 100644 --- a/autoload/airline/extensions/whitespace.vim +++ b/autoload/airline/extensions/whitespace.vim @@ -165,7 +165,7 @@ function! s:ws_refresh() endif unlet! b:airline_whitespace_check if get(g:, 'airline_skip_empty_sections', 0) - exe ':AirlineRefresh' + exe ':AirlineRefresh!' endif let b:airline_ws_changedtick = b:changedtick endfunction diff --git a/doc/airline.txt b/doc/airline.txt index 8104c0b7..c45b7f66 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -257,8 +257,9 @@ COMMANDS *airline-commands* :AirlineToggle *:AirlineToggle* Toggles between the standard 'statusline' and airline. -:AirlineRefresh *:AirlineRefresh* - Refreshes all highlight groups and redraws the statusline. +:AirlineRefresh[!] *:AirlineRefresh* + Refreshes all highlight groups and redraws the statusline. With the '!' + attribute, skips refreshing the highlighting groups. :AirlineExtensions *:AirlineExtensions* Shows the status of all available airline extensions. diff --git a/plugin/airline.vim b/plugin/airline.vim index b1f4a0b0..bf3d8411 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -195,14 +195,18 @@ function! s:airline_theme(...) endif endfunction -function! s:airline_refresh() +function! s:airline_refresh(...) + " a:1, fast refresh, do not reload the theme + let fast=!empty(get(a:000, 0, 0)) if !exists("#airline") " disabled return endif call airline#util#doautocmd('AirlineBeforeRefresh') call airline#highlighter#reset_hlcache() - call airline#load_theme() + if !fast + call airline#load_theme() + endif call airline#update_statusline() call airline#update_tabline() endfunction @@ -255,7 +259,7 @@ endfunction command! -bar -nargs=? -complete=customlist,get_airline_themes AirlineTheme call airline_theme() command! -bar AirlineToggleWhitespace call airline#extensions#whitespace#toggle() command! -bar AirlineToggle call s:airline_toggle() -command! -bar AirlineRefresh call s:airline_refresh() +command! -bar -bang AirlineRefresh call s:airline_refresh() command! AirlineExtensions call s:airline_extensions() call airline#init#bootstrap()