From 9143f8a8d0e88d8e6ccbfef1d1e219df59c29a53 Mon Sep 17 00:00:00 2001 From: Fitrah Muhammad <55179750+fitrh@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:22:30 +0800 Subject: [PATCH] enhance(filetype): filetype option as fallback of file extension for icon detection (#415) * enhance(filetype): filetype option precede extension for icon detection Enhances icon detection for files without extension e.g. shebang or modeline by using filetype option before the extension. * fixup(filetype): filetype option as fallback of file extension Some file icon keys defined by [nvim-web-devicons][1] using file extension name instead of filetype option. There's been an [issue][2] about this but no PR for it yet, so I think for now we can handle it here. [1]: https://github.com/kyazdani42/nvim-web-devicons [2]: https://github.com/kyazdani42/nvim-web-devicons/issues/29 * refactor(filetype): `vim.api.nvim_buf_get_option` -> `vim.bo` --- lua/lualine/components/filetype.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lualine/components/filetype.lua b/lua/lualine/components/filetype.lua index 89b74d2..120838a 100644 --- a/lua/lualine/components/filetype.lua +++ b/lua/lualine/components/filetype.lua @@ -30,6 +30,7 @@ function M:apply_icon() local ok, devicons = pcall(require, 'nvim-web-devicons') if ok then local f_name, f_extension = vim.fn.expand '%:t', vim.fn.expand '%:e' + f_extension = f_extension ~= '' and f_extension or vim.bo.filetype icon, icon_highlight_group = devicons.get_icon(f_name, f_extension) if icon and self.options.colored then