ryanoasis / vim-devicons

Adds file type icons to Vim plugins such as: NERDTree, vim-airline, CtrlP, unite, Denite, lightline, vim-startify and many more
MIT License
5.64k stars 265 forks source link

Wrong icons from WebDevIconsGetFileTypeSymbol function #399

Closed andriati-alex closed 3 years ago

andriati-alex commented 3 years ago

I'm using neovim latest version(0.5) on linux and I've noticed that the python icons were wrong in the lightline. Instead of the expected one it was showing the .txt files icon. For the icons in the lightline I was using the following function suggested in the wiki (slightly modified):

function! MyFiletype()
  return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
endfunction

and added the following in component_function section of the lightline : 'filetype': 'MyFiletype'. Running :echo WebDevIconsGetFileTypeSymbol() from any file with extension *.py were giving the txt file icon, although according to this function API it should take the name of opened file. To fix the bug, I used the function expand to provide the file name as input to WebDevIconsGetFileTypeSymbol, as such, I refactor the above function to:

function! MyFiletype()
  return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol(expand('%:t')) : 'no ft') : ''
endfunction

and now it is working as expected.

Maybe it is worth emphasizing that other plugins, as startify, are displaying correctly the icons for all files. I don't know if this problem is related strictly to latest neovim release(0.5) but I thought it was worth reporting it here since I haven't found any reports of this bug. I attached a screenshot of the behavior without using the argument expand('%:t') Screenshot_20210801_220319

get-me-power commented 3 years ago

It's may be same issue #402

get-me-power commented 3 years ago

@andriati-alex

I think I have fixed this bug. If you have any problems, please feel free to create an issue again.

andriati-alex commented 3 years ago

It's may be same issue #402

Yeah, same issue. I'll try again without this workaround I used above. Thank you.