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`
This commit is contained in:
parent
3f5cdc51a0
commit
9143f8a8d0
|
@ -30,6 +30,7 @@ function M:apply_icon()
|
||||||
local ok, devicons = pcall(require, 'nvim-web-devicons')
|
local ok, devicons = pcall(require, 'nvim-web-devicons')
|
||||||
if ok then
|
if ok then
|
||||||
local f_name, f_extension = vim.fn.expand '%:t', vim.fn.expand '%:e'
|
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)
|
icon, icon_highlight_group = devicons.get_icon(f_name, f_extension)
|
||||||
|
|
||||||
if icon and self.options.colored then
|
if icon and self.options.colored then
|
||||||
|
|
Loading…
Reference in New Issue