romgrk / barbar.nvim

The neovim tabline plugin.
2.17k stars 82 forks source link

Changing highlights from vim API #491

Closed TLSingh1 closed 1 year ago

Iron-E commented 1 year ago

What is the issue? Please provide a description 🙂

canvanaut commented 1 year ago
image

Not sure if this is related, but it seems that the highlight group for the barbar background has been changed.

Iron-E commented 1 year ago
image

Not sure if this is related, but it seems that the highlight group for the barbar background has been changed.

Certain default values did change in https://github.com/romgrk/barbar.nvim/pull/486 to more accurately reflect the intended usage of the built-in highlight groups (which helped to ensure the preset feature looked correct with minimal configuration)

The old look can be restored with :highlight or nvim_set_hl; I can write a snippet for that if you'd like.

canvanaut commented 1 year ago

Certain default values did change in https://github.com/romgrk/barbar.nvim/pull/486 to more accurately reflect the intended usage of the built-in highlight groups (which helped to ensure the preset feature looked correct with minimal configuration)

Ahh no wonder

I can write a snippet for that if you'd like

Yes please, I'm sure that'll be helpful for many users :))

TLSingh1 commented 1 year ago

I didnt realize I opened this, im so sorry.

@Iron-E you were super helpful earlier and solved my problem :) I will close this.

Iron-E commented 1 year ago

Yes please, I'm sure that'll be helpful for many users :))

Hopefully this helps:

-- WARN: must go before your colorscheme is sourced
vim.api.nvim_create_autocmd('ColorScheme', {
  callback = function()
    -- WARN: `vim.api.nvim_get_hl` only works in 0.9+.
    --       Use `nvim_get_hl_by_name for lower versions.

    local tabline = vim.api.nvim_get_hl(0, {link = false, name = 'TabLine'})
    for _, hl in ipairs(vim.fn.getcompletion('BufferDefaultCurrent*', 'highlight')) do
      local definition = vim.api.nvim_get_hl(0, {link = false, name = hl:gsub('Default', '')})
      definition.bg = tabline.bg
      definition.ctermbg = tabline.ctermbg
      vim.api.nvim_set_hl(0, hl, definition)
    end

    local tabline_fill = vim.api.nvim_get_hl(0, {link = false, name = 'TabLineFill'})
    for _, activity in ipairs {'Alternate', 'Inactive', 'Visible'} do
      for _, hl in ipairs(vim.fn.getcompletion('BufferDefault' .. activity .. '*', 'highlight')) do
        local definition = vim.api.nvim_get_hl(0, {link = false, name = hl:gsub('Default', '')})
        definition.bg = tabline_fill.bg
        definition.ctermbg = tabline_fill.ctermbg
        vim.api.nvim_set_hl(0, hl, definition)
      end
    end

    local special = vim.api.nvim_get_hl(0, {link = false, name = 'Special'})
    vim.api.nvim_set_hl(0, 'BufferScrollArrow', special)
    vim.api.nvim_set_hl(0, 'BufferTabpagesSep', special)
    vim.api.nvim_set_hl(0, 'BufferTabpages', special)
    vim.api.nvim_set_hl(0, 'BufferTabpagesSep', special)
  end,
  group = vim.api.nvim_create_augroup('config', {clear = false})
})
canvanaut commented 1 year ago

Thanks for the snippet! However, it seems like it's still not targeting the grey bar in the screenshot :(

Iron-E commented 1 year ago

Thanks for the snippet! However, it seems like it's still not targeting the grey bar in the screenshot :(

But some colors did change, right (i.e. the snippet applied)? Can you do :echo &tabline and report which highlight group is the one that's incorrect? I will try to make that snippet right for you if I can.

cattokomo commented 1 year ago

Hello, I also have the same problem. A grey bar appeared after I switched Neovim to 0.10-dev. I also tried the above snippet, and it doesn't work.

Here's the output of :echo &tabline

%1@barbar#events#main_click_handler@%#BufferCurrentSign#▎%#BufferCurrent#    %#DevIconLuaCurrent# %1@barbar#events#main_click_handler@%#Buffe
rCurrent#pm.lua%#BufferCurrent#    %1@barbar#events#close_click_handler@%#BufferCurrent#𝝬 %1@barbar#events#main_click_handler@%#BufferCurrentS
ignRight#%#BufferInactiveSign#▎%#BufferTabpageFill#
                               %0@barbar#events#main_click_handler@%#BufferTabpageFill#
Iron-E commented 1 year ago

@UrNightmaree @canvanaut does #500 help?

ahkohd commented 1 year ago

Any luck with solving this?

Iron-E commented 1 year ago

Any luck with solving this?

See https://github.com/romgrk/barbar.nvim/issues/491#issuecomment-1555973031. Otherwise, you can pin the latest stable version

cattokomo commented 1 year ago

@Iron-E Yes, it does fix it. Screenshot_20230521-121843_Termux

Iron-E commented 1 year ago

Merged to master. Thanks for confirming!