3

I'm trying to make transparent the tabline of the vim-airline, as in the second picture. I'm using the onedark colorscheme. They don't have a color specific for that. They use the same color variable for the statusbar and the cursorline. So if I put the following command in my init.vim, I change all three (tabline, statusbar and cursorline):

let g:onedark_color_overrides = {
\ "cursor_grey": { "gui": "#2C323C", "cterm": "NONE", "cterm16": "0" },
\}

I don't want to change the color of the cursorline.

I'm able to get the result I want for a specific session, using:

:hi airline_tabfill ctermbg=NONE

But I don't want to do this every time I open neovim. It doesn't work putting this command in the init.vim file.

Doing a little research, I found some people that put this command in a file in the ~/.vim/after/ directory. As I'm using neovim, I've tried this approach creating a file in the ~/.config/nvim/after/ directory. But it did nothing. I've also tried the ~/.config/nvim/after/plugin/ directory, and got nothing.

Interestingly, if I put this command in a file in the ~/.config/nvim/after/ftplugin/ directory, I get the result I want. However, in that way I need to create a file for every filetype I want this result and put that command. That is a horrible solution.

Any thought on how to do it in a more efficient way?

And can anyone tell me why I'm able to get this result putting the command hi airline_tabfill ctermbg=NONE in a file like tex.vim or python.vim in the ~/.config/nvim/after/ftplugin/ directory but can't do it for all filetypes putting this command in a file in the ~/.config/nvim/after/plugin/ directory?

Non-transparent tabline

Transparent tabline

5
  • Hi, thank you for the suggestions. I've tried all of the options you'd mentioned, but none of them seems to have worked. I've put autocmd FileType * hi airline_tabfill ctermbg=NONE and autocmd ColorScheme * hi airline_tabfill ctermbg=NONE before and after colorscheme onedark. But unortunely it didn't change anything.
    – rpmeira
    Commented Sep 2, 2021 at 0:57
  • I have airline and tried a couple things. I, too, couldn't change the highlight by just putting the statement in my vimrc but looking at the docs I found airline specific autocommands and this one seems to do the trick: autocmd User AirlineAfterInit hi airline_tabfill ...
    – B Layer
    Commented Sep 2, 2021 at 3:17
  • If this works for you let me know and I'll post a formal answer. (Which I'd appreciate you accepting...before you disappear forever...which happens a lot with first time question posters. :D )
    – B Layer
    Commented Sep 2, 2021 at 3:47
  • 1
    It worked! thank you so much, I really appreciate. Sure thing, I'll accept it.
    – rpmeira
    Commented Sep 2, 2021 at 11:11
  • Welcome to Vi and Vim!
    – D. Ben Knoble
    Commented Sep 3, 2021 at 18:21

1 Answer 1

3

As I alluded to in my (now deleted) comments this seemed to just be a matter of timing, i.e. you need some way to specify your hi customization such that it doesn't get clobbered by vim-airline's own setup.

Being a vim-airline user myself, I did :h airline then /autocommands. That quickly revealed that the plugin has five "user-defined" autocommands. Of the five, the one that seemed most likely to help was this one:

AirlineAfterInit : after plugin is initialized, but before the statusline is replaced

Source: :h airline-autocommands

So I tried putting the following in my vimrc:

augroup HITABFILL
    autocmd!
    autocmd User AirlineAfterInit hi airline_tabfill ctermbg=NONE
augroup END

And lo and behold it worked. (The "user-defined" part I mentioned above is how I knew to use User here since it's not explicitly mentioned in that section of the docs.)

2
  • 1
    Yay, after 2 years I don't have anymore light grey on dark grey inactive tabs...
    – RobM
    Commented Jul 26, 2022 at 7:02
  • 1
    @RobM LOL. Yay, after 1 year I don't have zero upvotes on this answer... ;) (And I just noticed I had a typo, too! The doc excerpt had one autocommand but the example used another.)
    – B Layer
    Commented Jul 28, 2022 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.