Commit Graph

72 Commits

Author SHA1 Message Date
Christian Brabandt
f3d6a3542a
Revert "highlighter: also check separator groups for being defined"
This reverts commit 99971aa24d.
2018-11-11 21:18:13 +01:00
Christian Brabandt
99971aa24d
highlighter: also check separator groups for being defined
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
2018-11-08 15:31:58 +01:00
Christian Brabandt
d57344a3c3
highlighter: skip more buffer related hi groups
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.
2018-11-08 13:32:20 +01:00
Christian Brabandt
496de8b745
highlighter: do not skip empty c_sections
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
2018-11-08 12:40:46 +01:00
Christian Brabandt
71dc6f0257
highlighter: fix regex typo 2018-11-08 12:24:02 +01:00
Christian Brabandt
09b5eb952c
highlighter: Only recreate hi groups for visible buffers
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
2018-11-08 12:20:55 +01:00
Christian Brabandt
b7367c605a
highlighter: do not redefine the same groups several times
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.
2018-11-07 14:25:40 +01:00
Christian Brabandt
2e99805dbf
Fix failing test 2018-10-16 12:13:24 +02:00
Christian Brabandt
726b730f0a
highlight: correctly cache and restore reverse attributes for highlighting colors
references #1779
2018-10-16 12:03:31 +02:00
Christian Brabandt
d81cdacb1e
better disabled highlighting for inactive windows on FocusLost
This will make sure that the current window will be highlighted as
expected, even if there are no other windows and all highlighting groups
will be correctly re-created as 'inactive'

references #1807
2018-10-16 10:49:17 +02:00
Christian Brabandt
b9f55455fb
Revert "highlighter: Make the separators use a cterm background color"
This reverts commit e72a7e2c8d.
2018-03-20 15:30:02 +01:00
Christian Brabandt
e72a7e2c8d
highlighter: Make the separators use a cterm background color
should fix: #1663
2018-03-19 22:24:57 +01:00
Christian Brabandt
5db4c408bd
Update copyright notifications 2018-01-05 10:37:59 +01:00
Christian Brabandt
cdaa5117b0
highlighter: also return bold flag 2017-09-01 11:25:37 +02:00
Christian Brabandt
470e9870f1
highlighter: do not consider 0 to be empty
fixes #1531
2017-08-20 22:47:02 +02:00
Christian Brabandt
a8c4424244
highligthing: Enable cacheing only when config is set.
This enables the highlighting caching only when the variable
g:airline_highlighting_cache is set to 1

Should make airline faster and more performant, because we can save a
lot of expensive C core calls. However, when redefining highlighting
groups, it might not correctly reset the cache.
2017-08-14 08:06:53 +02:00
Christian Brabandt
a96681d459
highlighter: Cache syntax highlighting attributes
Should in theory improve performance by quiet a lot.
2017-08-11 11:26:35 +02:00
Christian Brabandt
e9a7a12d9e
highlighter: improve performance of get_array() function 2017-08-11 11:05:56 +02:00
Christian Brabandt
c65d7fe36b
highlighter: slight performance increase
do not access get() function twice. We can assign the result to a
variable and use it a second time. Should speed up the highligther part
of the code by a bit.

Since I was already touching s:Get(), also get rid of the default
parameter, as it always has been the empty string.
2017-08-11 10:46:03 +02:00
Christian Brabandt
825aec9e4d
Revert "highlight: skip processing the same hi group twice"
This reverts commit feee9bcf3c.

It brakes CI and shouldn't be needed
2017-06-27 14:44:49 +02:00
Christian Brabandt
feee9bcf3c
highlight: skip processing the same hi group twice
Shouldn't happen, but just in case skip creating highlighting group,
if the same group with the same attributes has already been defined.
2017-06-26 23:17:43 +02:00
Christian Brabandt
583ae3d5f9
highlighter: skip create hi groups for inactive mode if not needed
This will skip creation of highlighting groups, if there are no inactive
windows.
2017-06-26 22:30:48 +02:00
Christian Brabandt
560092a9ec
highligher: fix the comparison before redefining hi group
The comparison in airline#highlighter#exec() was there to prevent to
call out to too many :hi calls by making sure that the newly to be
defined highlighting group will be actually different from the current
existing one.

However, that did not work, as the returned old highlight
group did never match the newly to be created one, since it
intentionally left the cterm attributes out for the gui and the gui
attributes for the terminal.

Therefore, fix the comparasion and make it compare the actual values
that we have.

This should make vim-airline a bit faster (hopefully!)
2017-06-26 22:27:01 +02:00
Christian Brabandt
57e564b227
Add termguicolor check for is_win32term
closes #1259
2017-06-21 15:44:58 +02:00
Christian Brabandt
87cdf8f6c4
highlighter: Make sure hi group exists and is valid
previously we only checked, that the group exists, however
if loading a new color scheme, this might lead to the group becoming
cleared. That means it still exists, but the highlighting group would
not show anything. Therefore, also check that the group is not cleared.

closes #1483
2017-06-21 09:19:51 +02:00
Christian Brabandt
17d2db93fd
Check, that fg color can't be negative 2017-03-13 18:50:19 +01:00
Christian Brabandt
134c0204f3
Do not return a negative background color
fixes #1429 and similar
2017-03-05 22:18:04 +01:00
Christian Brabandt
52663545a9
Only reset to Normal highlighting if it is actually defined
closes #1415 and similar
2017-02-28 08:33:44 +01:00
Christian Brabandt
f1574c4e0a
define highlighting group, if it not exists
previously, it could have been skipped, if the old highlighting
attribute was the same as the current one. However, if the group does
not exist, it should still be defined

closes #1404
2017-02-20 21:30:10 +01:00
Christian Brabandt
69b132a6f4
Make sure, the highlighting group will be defined
If a color value of ['', '', 'NONE', 'NONE', ''] is given as value to
the highlighting group, the resulting group definition would look like
this:

hi Normal ctermfg=NONE ctermbg=NONE

which would result in the highlighting group being cleared (or even no
set at all), therefore check that at least one other value exists and if
not fall back to the highlighting definition of the Normal group.
2017-02-20 21:30:10 +01:00
Christian Brabandt
583121bbc9
before trying to return hi attributes, check the group exists
This prevents trying to access twice the highlighting groups
and should slightly speed up airline.
2017-02-20 21:29:37 +01:00
Nate Soares
17b6bd9c8f Fixed bug where highlighting on inactive windows wouldn't refresh.
This seems to be an omission/regression from #afb75adc, where inactive
highlight updating was accidentally removed when fixing another bug.

Solution: Add back the deleted statement. closes #1339

Repro steps:
1. Install some theme that depends on the background color
   (Soares/base16.nvim has a bunch)
2. `set background=dark` in your vimrc, and `colorscheme` one of the
   aforementioned schemes.
3. Open a split window. Note the colors on the inactive window's airline.
4. `set background=light` manually. note the colors on the inactive
   window's airline. Note how they have not updated. (In particular,
   airline_c_inactive has updated, but all the other inactive groups
   have not.)
5. Enter the inactive window. Exit the inactive window. Observe that the
   colors are now correct (showing that it is in fact a problem with the
   airline load_theme code, and not with the theme).

It seems strange that the code as written only expects
airline_c_inactive to have styling; perhaps there is some norm that
themes are supposed to handle inactive windows in a particular way? For
the record, my theme dis omething like this:

```
let s:IA1   = s:airlist('similar1', 'similar2')
let s:IA2   = s:airlist('similar1', 'similar2')
let s:IA3   = s:airlist('similar1', 'similar2')
let g:airline#themes#{s:palette}#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3)
let g:airline#themes#{s:palette}#palette.inactive.airline_warning = s:airlist('base', 'contrast3')
let g:airline#themes#{s:palette}#palette.inactive.airline_error = s:airlist('base', 'antibase')
```
2016-12-09 12:53:35 +01:00
thawk
45d77ca909 Add 'scriptencoding utf-8' to all scripts 2016-09-24 08:16:30 +08:00
Christian Brabandt
73aea86a7a Do not unconditionally modify airline_c_inactive
consider a window with these splits:
,----
| file1
| ---
| file2
| ---
| file1
`----

If the top buffer is the active one and you start modifying this buffer,
this will also reset the highlighting for the inactive buffer2, since
the highlighting group 'airline_c_inactive' is used for both windows
(one having the unmodified buffer 'file2' and one having the modified
'file1').

This lead to the incorrect highlighting of the buffer name of file2.

Airline basically already created different airline_c<bufnr>_inactive
highlighting groups, but unfortunately did not use them.

Therefore, make the builder aware of this and always append the buffer
number to the group 'airline_c' if it is in an inactive window.

2) we need to make sure, the highlighting won't get overwritten, so
make the highlighter aware of this situation as well, by appending the
buffer number to the group name, if it creates the 'inactive' mode
groups and a buffer number has been given.

this fixes #1233
2016-09-08 18:46:11 +02:00
Ythildyr
afb75adc11 :AirlineRefresh not work correctly
If active buffer is modified, `:AirlineRefresh` apply `normal` highlight
instead of `normal_modified` highlight.

No particular config is requiered to reproduce this bug.

I see this bug with option `g:airline_skip_empty_sections` set.
Add any modification at the active buffer return to normal mode,
**do not save** and wait a few seconds, you can see highlight change to
normal but file is modified.

Without option `g:airline_skip_empty_sections`, add any modification at
the active buffer return to normal mode and type `:AirlineRefresh` you
can see change to bad highlight .
2016-08-28 14:41:45 +02:00
Daniel Hahler
f51f73773d airline#highlighter#exec: do not build cmd always 2016-06-06 20:41:33 +02:00
Daniel Hahler
429cfcd71e minor: do not copy args in s:get_array 2016-06-06 20:40:51 +02:00
Daniel Hahler
d39076a07d airline#highlighter: s:get_syn: fallback to 'NONE'
This is required when used with 'Normal' with a transparent background.
Falling back to 1 here results in "red" for "ctermbg"!

I think it's important to keep the 'NONE' color property here, instead
of hardcoding the fallbacks (even if white would be used instead of
red).
2016-02-16 00:44:07 +01:00
Christian Brabandt
af3f209d7a Try to avoid excessive redraws.
Most of them seem to be caused by using :hi statements, although the
highlighting group to be created is exactly the same. Therefore, get the
info from actual definition and only execute :hi when the new group is
actually different.

Also try to avoid to generate :hi statements when the popupmen is
visible. This causes flickers.
2016-02-06 13:55:28 +01:00
Christian Brabandt
87d60febaf fix neovim color mode 2016-02-05 22:47:57 +01:00
Andrea Schiavini
ef3746d022 Neovim support 2016-02-05 09:19:31 +01:00
Christian Brabandt
768a475add Better algorightm, to get msdos colors
currently, full 255 colors were returned, while in fact
msdos console only supports 16 colors. So fix this.
2016-01-27 20:37:58 +01:00
Christian Brabandt
5181d49a63 cmd.exe: Check for NONE/fg/bg of color value
Color values can have NONE/fg/bg values as well, and this would
error out.
2016-01-27 19:12:54 +01:00
Christian Brabandt
349ca86c71 Correct the comparison for given color codes
this issue fixes #758

The problem was, that a given color list ['','',0,'',''] was given to
the airline#highlighter#exec() function. This resulted in the following
comparison:

if (get(colors,2,'') != '')  ? 'ctermfg='.colors[2] : ''

which, since echo 0 != '' returns falls will return a single:

:hi group

and no color codes given and therefore, Vim would output the
current highlighting group.

Use isnot# as comparison to fix this issue.
2016-01-25 12:21:34 +01:00
Bailey Ling
048b24a916 happy 2016! 2016-01-14 21:38:38 -05:00
Eduardo Antunes C. de Sousa
7ea4b510af Dectect when vim.exe is running on ConEmu with 256 colors configured, so
it will use full color scheme.

More information on http://stackoverflow.com/questions/14315519/conemu-vim-syntax-highlight
2015-03-06 11:42:04 -03:00
Claudia Hardman
ac58bc9954 Add support for 24-bit colors with +termtruecolor flag 2015-02-16 12:00:52 -05:00
Bailey Ling
1ca6ffb6d0 happy 2015
resolves #692.
2015-02-13 21:47:43 -05:00
Bailey Ling
09817e0984 fix regression with serene theme, #599 2014-11-15 19:49:02 +00:00
Bailey Ling
be6e4d6dd6 check background of groups to determine transition. resolves #599. 2014-11-09 00:52:42 -05:00