romgrk / barbar.nvim

The neovim tabline plugin.
2.16k stars 81 forks source link

No devicons for .txt files #552

Closed m147 closed 4 months ago

m147 commented 4 months ago

Barbar does not display devicon for .txt files. Displays only []

To Reproduce

Screenshots barbar_txt

Iron-E commented 4 months ago

I wasn't able to reproduce. Does this icon appear when using nvim-web-devicons in other plugins?

m147 commented 4 months ago

I don't think I have any other plugins that use nvim-web-devicons. I have NERDTree which uses another devicon plugin. I tried removing that plugin to see if there is a conflict but that was not the issue.

Iron-E commented 4 months ago

Can you run this from a txt file and share the result?

require('nvim-web-devicons').get_icon_by_filetype(vim.api.nvim_get_option_value('filetype', {}))

(I'm on a phone so the syntax might not be 100% accurate, if it doesn't work I'll post a working version tomorrow)

m147 commented 4 months ago

Can you run this from a txt file and share the result?

require('nvim-web-devicons').get_icon_by_filetype(vim.api.nvim_get_option_value('filetype', {}))

(I'm on a phone so the syntax might not be 100% accurate, if it doesn't work I'll post a working version tomorrow)

You mean open a text file and run the above as a vim commad?

Iron-E commented 4 months ago

Can you run this from a txt file and share the result?

require('nvim-web-devicons').get_icon_by_filetype(vim.api.nvim_get_option_value('filetype', {}))

(I'm on a phone so the syntax might not be 100% accurate, if it doesn't work I'll post a working version tomorrow)

You mean open a text file and run the above as a vim commad?

Yeah; whenever a file is currently focused that has the bug from the screenshot.

You can do := some_lua_code_here in recent Neovim versions for that.

Sorry for any confusion!

m147 commented 4 months ago

No worries, I hadn't included the = when running the command. This doesn't do anything that I can see.

Iron-E commented 4 months ago

No worries, I hadn't included the = when running the command. This doesn't do anything that I can see.

What version are you on? It might be necessary to do :lua vim.pretty_print(expression_goes_here) instead.

Alternatively, checking :messages might reveal the output

m147 commented 4 months ago

Version: NVIM v0.9.5 Build type: Release LuaJIT 2.1.1702233742

I tried the above, first it warned me to use vim.print instead of vim.pretty_print as that is deprecated. The output was

devicon

m147 commented 4 months ago

I tried making a file foo.text rather that .txt the icon shows properly. Not sure why it doesn't work with .txt. Also, I'm quite sure this is recent. I don't remember seeing this before.

Iron-E commented 4 months ago

vim.pretty_print as that is deprecated

Yeah, pretty printing is the old way of doing that. := and vim.print are the new ways

I tried making a file foo.text rather that .txt the icon shows properly

My present ideas as to a cause are:

Does this line show in Neovim properly? If so, that eliminates the notion that this is a font issue and makes it more likely to be a filetype error.

m147 commented 4 months ago

It does not. Shows the same box as in barbar

m147 commented 4 months ago

I'm able to get the icon working properly with:

require'nvim-web-devicons'.setup { override_by_extension = { ["txt"] = { icon = "", color = "#81e043", name = "txt" } }; } in init.vim

m147 commented 4 months ago

It seems this is an issue with nvim-web-devicons and not barbar.

I should have read this notice on its GitHub page:

Notice Nerd fonts moved some symbols with version 3.0. Version 2.3 is meant for transition, supporting both version 2 and version 3 icons. Nvim-web-devicons requires version 2.3 or above to work properly. If you are unable to update please use your plugin manager to pin version of nvim-web-dev icons to nerd-v2-compat tag.

Plug 'kyazdani42/nvim-web-devicons', { 'tag': 'nerd-v2-compat' } solves the issue.

One way or another, you helped me track down where the issue lies. Thank you.

Iron-E commented 4 months ago

Happy to help!