lualine.nvim icon indicating copy to clipboard operation
lualine.nvim copied to clipboard

Bug: lualine doesn't show filetype icon for files without extension

Open kassio opened this issue 3 years ago • 2 comments
trafficstars

The 'filetype' component doesn't find the filetype icon sometimes:

_HOME_src_gdk_gitlab_a_rb
My config
lualine.setup({
  extensions = {
    require('plugins.statusline.extensions.filetree'),
    require('plugins.statusline.extensions.neoterm'),
  },
  options = {
    theme = theme.colorscheme,
    icons_enabled = true,
    section_separators = '',
    component_separators = '',
  },
  sections = {
    lualine_a = { utils.bufnr() },
    lualine_b = {
      {
        'filetype',
        colored = true,
        icon_only = true,
        padding = 1,
      },
      {
        'filename',
        file_status = true,
        path = 1,
        shorting_target = 30,
        symbols = { modified = ' ', readonly = ' ', unnamed = ' [No Name] ' },
        padding = 0,
      },
    },
    lualine_c = {
      { vim.my.treesitter.gps.location },
    },
    lualine_x = {
      {
        'diagnostics',
        sources = { 'nvim_diagnostic' },
        symbols = {
          error = theme.signs.error,
          warn = theme.signs.warn,
          hint = theme.signs.hint,
          info = theme.signs.info,
        },
        color_error = theme.colors.error,
        color_warn = theme.colors.warn,
        color_hint = theme.colors.hint,
        color_info = theme.colors.info,
      },
    },
    lualine_y = { 'diff' },
    lualine_z = {
      { '[[%3l:%-3c]]' },
      utils.mode(),
    },
  },
  inactive_sections = {
    lualine_a = { utils.bufnr() },
    lualine_b = utils.filename({ icon_color = false }),
    lualine_c = {},
    lualine_x = {},
    lualine_y = {},
    lualine_z = {},
  },
})

Self Checks

  • [x] I'm using the latest lualine.
  • [x] I didn't find the issue in exsisting issues or prs.

How to reproduce the problem

I'm not sure, but it seems related to how the filetype is set, when it's set in ftdetect with BufReadPos it doesn't set the icon.

Expected behaviour

Actual behaviour

Minimal config to reproduce the issue

Config

kassio avatar Feb 14 '22 17:02 kassio

nvim-web-devicons uses it's own filetype detection for icons. It only allows us to ask for icons based on extensions. There's an issue open there to add support for filetype based icons . This issue can't be fixed without that and that issue is open for over am year so 🤷‍♂️

shadmansaleh avatar Feb 15 '22 05:02 shadmansaleh

The workaround to this kind of issue is to override nvim-web-devicon config

local devicons = require("nvim-web-devicons")
local icons = devicons.get_icons()

devicons.setup({
  override = {
    ruby = icons["rb"],
  },
})

fitrh avatar Feb 28 '22 05:02 fitrh