Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

airline_b & airline_c sections are missing if I set their bg and fg color of COMMANDLINE mode as the same as airline_a's #2298

Open
bekcpear opened this issue Dec 2, 2020 · 5 comments

Comments

@bekcpear
Copy link

bekcpear commented Dec 2, 2020

environment

  • vim: NVIM v0.4.4
  • vim-airline: latest
  • OS: Gentoo
  • reproduced with a minimal vimrc: YES
  • airline configuration:
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline_theme = 'lessnoise'
let g:airline#extensions#tabline#enabled = 1 
  • terminal: konsole
  • $TERM variable: xterm-256color
  • color configuration (:set t_Co?): t_Co=256
  • does it happen in Vim: YES

actual behavior

Usually, the statusline looks like this:

  • Normal mode Screenshot_20201202_185450
  • Command line mode Screenshot_20201202_190052

However, after I opened a new buffer or window in current tab, the stausline changed to Screenshot_20201202_190246
It's very strange, the a, b and c sections got the same colors and font style although it has returned to the NORMAL mode.

what did I do

I create a new theme lessnoise.vim. I want to use the same fg and bg color for airline_a, b and c when in COMMANDLINE mode, and these are defined at line 116 of my theme file.

At first, I couldn't determine whether it was the vim-airline problem or the vim/neovim problem, so I went to check the vim-airline and vim codes. After doing a lot of testing, I found it's a vim-airline problem:

Vim-airline changes group to a different one according to the different colors instead of the exactly group name since be6e4d6 and 09817e0 due to the issue #599. So, using command line to open a new buffer makes the statusline has only one airline_a left section if I configured same colors for airline_a, airline_b and airline_c.

I tried to solve this problem by myself but failed. If I add a new condition to judge if the airline_b group contained like this commit bekcpear@9709eb0, the left sections will be okay, but the right sections broken still because of same colors defined in the NORMAL mode, like this: Screenshot_20201202_194709
the airline_z group broken.

Of cause, I can add another condition to judge the sections on the right, but I think it's dirty. And I also think using configured colors to change group is not very good.

I also tried to refactor the other functions related to should_change_group(), but.. it's too large.., and if the alt_sep symbol should be displayed when continued groups have same colors and sep symbol should be displayed when they have different colors, the statusline's context.line should be rebuild every time it triggered. I don't know if this will affect performance and is there any other better solution.

Currently, I will try to change my theme to judge the runtime environment(GUI or TUI), and change the unused colors to get around this problem.

@chrisbra
Copy link
Member

chrisbra commented Dec 2, 2020

this is tricky. not sure what the best way around this is. Can you provide your theme please?

@bekcpear
Copy link
Author

bekcpear commented Dec 2, 2020

this is my theme for now: lessnoise.vim, actually it was quoted above.

Although I can get around this problem by changing the theme, I still feel that this problem should be solved by vim-airline self.

@chrisbra
Copy link
Member

chrisbra commented Dec 2, 2020

Although I can get around this problem by changing the theme, I still feel that this problem should be solved by vim-airline self.

Perhaps. I think the implicitly, vim-airline assumes, that different highlighting groups need to be - well - different, that means use different color attributes. And this is where you run into problems. Perhaps it is possible to use attributes like underline,italic etc to make vim-airline think those groups are actually different. So e.g. if you only use the gui, use term=underline and for the terminal use gui attributes like gui=underline so that the definition of the groups is actually different, but those differences are not used in whatever UI you are using.

@bekcpear
Copy link
Author

bekcpear commented Dec 2, 2020

I think the implicitly, vim-airline assumes, that different highlighting groups need to be - well - different, that means use different color attributes.

Agree, but, the statusline's context.line variable is not always changed.

let a:context.line = builder.build()

For my theme, in the command line mode, a, b, c and other sections are the same(ignore italic), so there is no problem with only one a group. When vim go back to the normal mode after a new buffer opened, still only one a group existed in the left section although the a and b sections have different color attributes in my theme, due to the unchanged statusline's context.line.

This problem may can be solved by keeping the context.line variable changing if performance is not affected.

@physical-eng
Copy link

In my case, this problem solved by reloading colorscheme at end of airline#mode_changed.
(it's though not essential solution.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants