nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
6.22k stars 467 forks source link

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

Closed kassio closed 2 years ago

kassio commented 2 years ago

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

_HOME_src_gdk_gitlab_a_rb
My config ```lua 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

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

Aditional information

shadmansaleh commented 2 years ago

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 🤷‍♂️

fitrh commented 2 years ago

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"],
  },
})