nvim-tree / nvim-web-devicons

lua `fork` of vim-web-devicons for neovim
MIT License
2.08k stars 185 forks source link

Wrong devicon when .vimrc/.zshrc opened from startify screen #58

Closed poetaman closed 3 years ago

poetaman commented 3 years ago

The devicons for files like .vimrc, .zshrc is incorrect when file is opened from vim-startify screen. The icons are correct if these files are opened directly using commands like :e .vimrc<CR>/ :e.zshrc<CR>. The same problem does not occur for most of the other file types (including files that end in .vim).

Steps to recreate:

  1. Install vim-startify
  2. Reopen nvim
  3. Open .vimrc file using usual command :e .vimrc<CR>.
  4. Close, and reopen nvim
  5. Open .vimrc file by pressing <CR> on .vimrc file in the MRU buffer list of vim-startify's startup screen.
kyazdani42 commented 3 years ago

are your sure this issue is realted to nvim-web-devicon and not vim-startify ? This plugin only provide a simple function, the rest is left to the plugin developers to implement.

poetaman commented 3 years ago

@kyazdani42 I would think more a nvim-web-devicon question. vim-startify developer could argue its just a start-screen that can be used to open MRU or other important files. What can he do wrong in opening files? If there is an interest in fixing this then one of you will have to decide to debug a bit. @mhinz, any opinion? I think it is worthwhile as vim-startify & nvim-web-devicons are a good combination, and each worth using in its own right.

kyazdani42 commented 3 years ago

waiting for @mhinz before going on further investigation, i'm not sure why most plugins would work as expected using this lib but not vim-startify ? If this issue comes from nvim-web-devicon, i will fix it.

mhinz commented 3 years ago

By default, startify isn't using nvim-web-devicons. Following the steps above, I see nothing happening in startify.

What else do I have to do to reproduce this issue?

kyazdani42 commented 3 years ago

if vim-startify doesn't use nvim-web-devicons, how is this issue relevant ?

poetaman commented 3 years ago

I have a mp4 video, and minimal example. It could most likely be a problem of nvim-bufferline.lua. Adding @akinsho. Am sorry I forgot there are 3 packages involved here. Please keep your eyes on the command I send to nvim, and the icon that gets show in the bufferline on top.

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath=&runtimepath

call plug#begin('~/.vim/plugged')
Plug 'mhinz/vim-startify'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'akinsho/nvim-bufferline.lua'
call plug#end()

let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
lua require'bufferline'.setup{}

lua <<EOF
require'nvim-web-devicons'.setup {
 -- your personnal icons can go here (to override)
 -- DevIcon will be appended to `name`
 override = {
  zsh = {
    icon = "",
    color = "#cb4b16",
    name = "zsh",
  },
  vim = {
    icon = "",
    color = "#719e07",
    name = "vim",
  },
--  vimrc = {
--    icon = "",
--    color = "#719e07",
--    name = "vim",
--  },
  lua = {
    icon = "",
    color = "#b58900",
    name = "lua",
  },
  pdf = {
    icon = "",
    color = "#719e07",
    name = "pdf",
  },
  tex = {
    icon = "ﭨ",
    color = "#dc322f",
    name = "tex",
  },
 };
 -- globally enable default icons (default to false)
 -- will get overriden by `get_icons` option
 default = true;
}

EOF

MP4 video:

As can be seen from the video, then the files are opened with path like :e ~/.zshrc, buffer line does not show correct icons. I guess I associated it with Startify was because for some MRU entries hitting <CR> on them would have used a full path like one above, and produced different result.

https://user-images.githubusercontent.com/71736629/118935039-edc1bb80-b8ff-11eb-8b28-63321988a92a.mp4

kyazdani42 commented 3 years ago

i think it's because you initialize nvim-web-devicons after bufferline which already have initialized it. Try to put your nvim-web-devicon setup before all other plugins initializations if you want changes to take effect properly.

poetaman commented 3 years ago

@kyazdani42 I tried couple of refactorings, it didn't change anything. Can you please check if/how these lines need to be rearranged? Please post it too...

kyazdani42 commented 3 years ago

after looking at the video you sent, i'm completely sure this issue should be addressed to bufferline. I'm closing this because it's out of the scope of this library.

kyazdani42 commented 3 years ago

PS: feel free to reference your issue to this one