Only show the "airline theme not found" warning message, when the user
actually used `:AirlineTheme foobar`, not when called by an autocommand
that tries to switch themes when the Vim colorscheme changed.
fixes#1824
While this adds a bit more code it makes it possible to distinguish
between themes not found and errors in themes.
Use :verbose AirlineTheme <foobar>
to also see the error message in case of errors.
remove autocommand, that would overwrite the airline theme on :term
(e.g. After a :AirlineTheme monochrome and then using `:term` the
autocommand would reset the theme back to the one given in the .vimrc)
Groupnames like 'airline_c1_to_airline_x_inactive' still have to be
processed, so do not skip them.
Also for the tabline, '_inactive' groups are not used, so skip them
In 781c40bb3d the AirlineModeChanged user-defined
autocommand has been introduced. However it was forgotten to mention
this actually in the documentation.
So here we go.
closes#1774
Replace by a function that retuns the to be executed highlighting string
Should in theory be a bit faster, since the same function does not have
to be called 5 times per highlighting group.
It probably is not much better, but here are some random numbers:
Profiling:
Previously:
count total (s) self (s)
199 0.022973 0.009909 let cmd = printf('hi %s %s %s %s %s %s %s %s', a:group, s:Get(colors, 0, 'guifg=')…
New:
count total (s) self (s)
79 0.010166 0.000862 let cmd = printf('hi %s%s', a:group, s:GetHiCmd(colors))
Make sure, to also check, if the separator groups have already been
defined. Once they are defined initially, they are usually available in
the palette group. So do not redefine them once they have been created
initially.
references #1779
Previously, we only checked for if the name starts with 'airline_c'
But there could as well be highlighting groups starting being called
'airline_b_to_airline_c5', but if buffer 5 is no longer visible in the
current viewport, then we do not need to recreate those groups.
currently, if the matchstr() evaluates to '', it would skip the required
section, because bnr would be evaluated to zero and since there is no
buffer zero, skip that highlighting group.
Make sure, to only skip the highlighting group if the buffer number is
actually > 0
In a long editing session, there could happen to accumulate several
highlighting groups for buffers that might no longer be visible.
Therefore, only re-create the highlighting group for buffers that are
actually displayed in the current tabpage. If not, skip them.
references #1779
previously, it could happen that the same highlighting group was defined
several times, because it was available in several modes within
g:airline#theme[mode]. So the second one would always win.
Therefore, loop through all modes in reverse order and define the group
and remember what group has already been defined. If we happen to have
to re-define the same group, skip it. Since we are traversing the list
in reverse order, this should make sure the last definition wins.
This has the benefit of being more performant and hopefully helps with
e.g. #1779 and similar issues.