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

[Bug]: Incorrect length of underline when display lsp diagnostics indicator #970

Open
1 task done
heddxh opened this issue Oct 17, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@heddxh
Copy link

heddxh commented Oct 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

When showing diagnostics indicator after lsp have been prepared, the underline is split, length is too small.

图片

What did you expect to happen?

The underline fill all length of the tab/buffer.

Config

{
  'akinsho/bufferline.nvim',
  event = 'VeryLazy',
  keys = {
    { '<leader>bp', '<Cmd>BufferLineTogglePin<CR>', desc = 'Toggle Pin' },
    { '<leader>bP', '<Cmd>BufferLineGroupClose ungrouped<CR>', desc = 'Delete Non-Pinned Buffers' },
    { '<leader>bo', '<Cmd>BufferLineCloseOthers<CR>', desc = 'Delete Other Buffers' },
    { '<leader>br', '<Cmd>BufferLineCloseRight<CR>', desc = 'Delete Buffers to the Right' },
    { '<leader>bl', '<Cmd>BufferLineCloseLeft<CR>', desc = 'Delete Buffers to the Left' },
    {
      '<leader>bq',
      function()
        MiniBufremove.delete()
      end,
      desc = '[Q]uit current [B]uffer',
    },
    { '<S-h>', '<cmd>BufferLineCyclePrev<cr>', desc = 'Prev Buffer' },
    { '<S-l>', '<cmd>BufferLineCycleNext<cr>', desc = 'Next Buffer' },
    { '[b', '<cmd>BufferLineCyclePrev<cr>', desc = 'Prev Buffer' },
    { ']b', '<cmd>BufferLineCycleNext<cr>', desc = 'Next Buffer' },
    { '[B', '<cmd>BufferLineMovePrev<cr>', desc = 'Move buffer prev' },
    { ']B', '<cmd>BufferLineMoveNext<cr>', desc = 'Move buffer next' },
  },
  config = function(_, opts)
    require('bufferline').setup(vim.tbl_deep_extend('force', opts, { ---@type bufferline.Options
      options = {
        indicator = { style = 'underline' },
        always_show_bufferline = false,
        diagnostics = 'nvim_lsp',
        diagnostics_indicator = function(_, _, diagnostics_dict, _)
          local s = ' '
          for e, n in pairs(diagnostics_dict) do
            local sym = e == 'error' and '' or (e == 'warning' and '' or '')
            s = s .. sym
          end
          return s
        end,
        offsets = {
          {
            filetype = 'neo-tree',
            text = 'Neo-Tee',
            highlight = 'Document',
            separator = '', -- TODO: choose a thinner symbol
          },
        },
        color_icons = true,
        show_buffer_close_icons = false,
        tab_size = 15,
        separator_style = 'slant',
        custom_filter = function(buf, bufnums)
          if vim.bo[buf].filetype == 'qf' then
            return false
          end
          -- Ignore unnamed buffers
          if vim.api.nvim_buf_get_name(buf) == '' then
            return false
          end
          return true
        end,
      },
    }))
    -- Fix bufferline when restoring a session
    vim.api.nvim_create_autocmd({ 'BufAdd', 'BufDelete' }, {
      callback = function()
        vim.schedule(function()
          pcall(nvim_bufferline)
        end)
      end,
      desc = 'Fix bufferline when restoring a session',
    })
  end,
}

Additional Information

No response

commit

0b2fd86

@heddxh heddxh added the bug Something isn't working label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant