akinsho / bufferline.nvim

A snazzy bufferline for Neovim
GNU General Public License v3.0
3.49k stars 197 forks source link

[Bug]: Language icons are wrong. #474

Closed bokutotu closed 2 years ago

bokutotu commented 2 years ago

Is there an existing issue for this?

What happened?

The language icons are wrong.

Screen Shot 2022-07-12 at 2 02 20

As you can see in this image, unfamiliar characters are displayed where the language icons should appear. The left portion should show the language icon, but it does not.

What did you expect to happen?

I want to display the following icons in README.md

Screen Shot 2022-07-12 at 2 02 20

Config

this is my config file

 local fn = vim.fn

  local function diagnostics_indicator(_, _, diagnostics)
    local symbols = { error = ' ', warning = ' ', info = 'ℹ️' } 
    local result = {}
    for name, count in pairs(diagnostics) do
      if symbols[name] and count > 0 then
        table.insert(result, symbols[name] .. count)
      end
    end
    result = table.concat(result, ' ')
    return #result > 0 and result or ''
  end

  local function custom_filter(buf, buf_nums)
    local logs = vim.tbl_filter(function(b)
      return vim.bo[b].filetype == 'log'
    end, buf_nums)
    if vim.tbl_isempty(logs) then
      return true
    end
    local tab_num = vim.fn.tabpagenr()
    local last_tab = vim.fn.tabpagenr('$')
    local is_log = vim.bo[buf].filetype == 'log'
    if last_tab == 1 then
      return true
    end
    -- only show log buffers in secondary tabs
    return (tab_num == last_tab and is_log) or (tab_num ~= last_tab and not is_log)
  end

  local groups = require('bufferline.groups')

  require('bufferline').setup({
    options = {
      debug = {
        logging = true,
      },
      indicator_icon = '▎',
      buffer_close_icon = '',
      modified_icon = '●',
      close_icon = '',
      left_trunc_marker = '',
      right_trunc_marker = '',
      mode = 'buffers', -- tabs
      sort_by = 'insert_after_current',
      right_mouse_command = 'vert sbuffer %d',
      show_close_icon = false,
      ---based on https://github.com/kovidgoyal/kitty/issues/957
      -- separator_style = os.getenv('KITTY_WINDOW_ID') and 'slant' or 'padded_slant',
      show_buffer_close_icons = true,
      diagnostics = 'nvim_lsp',
      diagnostics_indicator = diagnostics_indicator,
      diagnostics_update_in_insert = false,
      custom_filter = custom_filter,
      offsets = {
        {
          filetype = 'undotree',
          text = 'Undotree',
          highlight = 'PanelHeading',
        },
        {
          filetype = 'NvimTree',
          text = 'Explorer',
          highlight = 'PanelHeading',
        },
        {
          filetype = 'neo-tree',
          text = 'Explorer',
          highlight = 'PanelHeading',
        },
        {
          filetype = 'DiffviewFiles',
          text = 'Diff View',
          highlight = 'PanelHeading',
        },
        {
          filetype = 'flutterToolsOutline',
          text = 'Flutter Outline',
          highlight = 'PanelHeading',
        },
        {
          filetype = 'Outline',
          text = 'Symbols',
          highlight = 'PanelHeading',
        },
        {
          filetype = 'packer',
          text = 'Packer',
          highlight = 'PanelHeading',
        },
      },
      groups = {
        options = {
          toggle_hidden_on_enter = true,
        },
        items = {
          groups.builtin.ungrouped,
          {
            name = 'Terraform',
            matcher = function(buf)
              return buf.name:match('%.tf') ~= nil
            end,
          },
          {
            highlight = { guisp = '#51AFEF', gui = 'underline' },
            name = 'tests',
            icon = '💯',
            matcher = function(buf)
              return buf.filename:match('_spec') or buf.filename:match('_test')
            end,
          },
          {
            name = 'docs',
            icon = '',
            matcher = function(buf)
              for _, ext in ipairs({ 'md', 'txt', 'org', 'norg', 'wiki' }) do
                if ext == fn.fnamemodify(buf.path, ':e') then
                  return true
                end
              end
            end,
          },
        },
      },
    },
  })

  require('which-key').register({
    ['gD'] = { '<Cmd>BufferLinePickClose<CR>', 'bufferline: delete buffer' },
    ['gb'] = { '<Cmd>BufferLinePick<CR>', 'bufferline: pick buffer' },
    ['<leader><tab>'] = { '<Cmd>BufferLineCycleNext<CR>', 'bufferline: next' },
    ['<S-tab>'] = { '<Cmd>BufferLineCyclePrev<CR>', 'bufferline: prev' },
    ['[b'] = { '<Cmd>BufferLineMoveNext<CR>', 'bufferline: move next' },
    [']b'] = { '<Cmd>BufferLineMovePrev<CR>', 'bufferline: move prev' },
    ['<leader>1'] = { '<Cmd>BufferLineGoToBuffer 1<CR>', 'which_key_ignore' },
    ['<leader>2'] = { '<Cmd>BufferLineGoToBuffer 2<CR>', 'which_key_ignore' },
    ['<leader>3'] = { '<Cmd>BufferLineGoToBuffer 3<CR>', 'which_key_ignore' },
    ['<leader>4'] = { '<Cmd>BufferLineGoToBuffer 4<CR>', 'which_key_ignore' },
    ['<leader>5'] = { '<Cmd>BufferLineGoToBuffer 5<CR>', 'which_key_ignore' },
    ['<leader>6'] = { '<Cmd>BufferLineGoToBuffer 6<CR>', 'which_key_ignore' },
    ['<leader>7'] = { '<Cmd>BufferLineGoToBuffer 7<CR>', 'which_key_ignore' },
    ['<leader>8'] = { '<Cmd>BufferLineGoToBuffer 8<CR>', 'which_key_ignore' },
    ['<leader>9'] = { '<Cmd>BufferLineGoToBuffer 9<CR>', 'which_key_ignore' },
  })

Additional Information

The editor I use is kitty and I run neovim via tmux.

commit

No response

akinsho commented 2 years ago

@bokutotu the most likely issue for this is some conflict between the font you are using and i.e. is it patched and whether your terminal respects that. This plugin doesn't really control the rendering of fonts in the terminal. It's important to note that in the screenshot you are showing the highlight for the icon is rendered next to bold font, so it might be the case that your bold font variant is not patched. Can you please confirm that all the fonts you are using are patched and that you are able to see patched fonts in other scenarios?

If not, I strongly recommend you investigate how to set that up and retest. Please note that helping set up patched fonts is not something that should be dealt with here as this is covered in other places like blog posts, GitHub repos etc.

akinsho commented 2 years ago

I'm going to close this out since I really don't think this relates to this plugin. How an icon appears in the terminal is way lower level than anything this plugin does. This seems much more likely to be an issue somewhere between the font and the terminal