nvim-lualine / lualine.nvim

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

Feat: Icons per file type #475

Closed bryant-the-coder closed 2 years ago

bryant-the-coder commented 2 years ago

Is it possible to add like when i open a lua file... then there will be a lua icon. Html file with html icon. Is it possible?

shadmansaleh commented 2 years ago

filetype component already supports icons by default . You need to install nvim-web-devicons for that to work.

If you want just the icon you can use icon_only option

bryant-the-coder commented 2 years ago

I mean beside filename...

shadmansaleh commented 2 years ago

I mean beside filename...

No filename component doesn't have icons out of the box . But you can create a custom filename component with that functionality .

bryant-the-coder commented 2 years ago

like how?

shadmansaleh commented 2 years ago

like how?

You can just reuse the apply_icon method from filetype component in your custom filename component to easily get icons with filename.

For example

local my_filename = require('lualine.components.filename'):extend()
my_filename.apply_icon = require('lualine.components.filetype').apply_icon

require'lualine'.setup {
  lualine_c = {{my_filename, colored = true}},
}
bryant-the-coder commented 2 years ago

thanks

dave-kennedy commented 1 year ago

You also need to set my_filename.icon_hl_cache = {} or remove colored = true from options.