fgheng / winbar.nvim

winbar config for neovim
111 stars 22 forks source link

Consider alternative filetype for icons #24

Open ColinKennedy opened 1 year ago

ColinKennedy commented 1 year ago

Firstly I wanted to say that I love this plug-in! Often, I find that just the statusline isn't enough space to communicate all that I'd like to see and winbar.nvim has been so helpful. That said I wanted to point out a possible improvement.

I've been working with nvim-dap-ui lately and winbar.nvim looks like this, by default:

Screenshot from 2023-04-23 12-33-45

I wondered why all of the icons were the same and, it turns out, nvim-dap-ui sets each buffer's filetype rather than file extension. winbar.nvim currently only considers the file extension when trying to grab an icon from nvim-web-devicons.

I made a slight tweak to winbar.nvim's source to allow that check

local winbar_file = function()
    local file_path = vim.fn.expand('%:~:.:h')
    local filename = vim.fn.expand('%:t')
    local file_type = vim.fn.expand('%:e')  -- Note, this is actually an extension, not a file type

+   if file_type == ""
+   then
+       file_type = vim.api.nvim_buf_get_option(0, "filetype")
+   end

and now it looks like this

Screenshot from 2023-04-23 12-36-28

It's a minor thing but it'd be cool if this got upstreamed along with an explicit call to webicon's get_icon_by_filetype API function. Either way I can always use my fork. Thanks for making this plug-in!