0

I have patched my own nerd-font and I want those cool icons for each file-type to be shown in the name of tab in Vim/NeoVim. I guess this can be done easily like I have customized my zsh command prompt as shown below with one line. But I don't know how to do that, and I have searched many projects/plugins on GitHub but it feels like this can be down without a plugin.

My zshrc to customize the command prompt:

PROMPT='%(?.%B%F{green}‚úî.%F{red}‚úò:%?)%b %F{208}%n%f %F{240}%3~%f %# '

which looks like:

What I want is something like this: (Picture from barbar.vim, but I think it provides too much functions than what I actually need)


My current nvim looks like this:

NeoZoom.lua
  • 1,442
  • 14
  • 31
  • 1
    I think everyone should use Vim in whatever way they prefer to use Vim but just in case you're unaware, here's some good info about how Vim's tabs are not tabs in the traditional sense. (Your request for file type icons suggests you are using tabs with a one tab = one file model.) How to use tabs, "proper" usage of buffers. Read if you're so inclined...no pressure. :) Cheers. – B Layer Apr 11 '21 at 06:04
  • @BLayer: Thanks for the info. :) I will definitely read it. – NeoZoom.lua Apr 11 '21 at 06:11
  • Indeed I've created some shortcuts to split(e.g. create a split on the right of current window nnoremap <C-W><C-L> :vsp<CR><C-W><C-L>) and to maximize that split, but then I just asked myself "Won't it be more convenient to just create a new tab(1 step, no need to maximize it) than create a split and maximize it(2 steps)?" As you can see I don't know about when to use tabs/buffers/windows. – NeoZoom.lua Apr 11 '21 at 06:14
  • 1
    @BLayer: Thanks for all links! I've watched How to use tabs and was reading reddit thread, with the SO question open in my Edge tab(the GUI-sense tab). – NeoZoom.lua Apr 11 '21 at 06:45
  • 1
    :help tabline – D. Ben Knoble Apr 11 '21 at 11:09
  • 1
  • 1
    And of course :h setting-tabline and :h setting-guitablabel. – Matt Apr 11 '21 at 19:03
  • 1
    @BLayer: I'm happy to tell you that I'm familiar with buffers and vim-tabs now :) A vim-tab for me is to design a window-layout, while a buffers is kind-of a browser-tab but it can hide(no showing) behind all window-layout or share between different vim-tabs, this is indeed useful. I feel like I'm hot-roding a car when I understand more about Vim, thank you! – NeoZoom.lua Apr 11 '21 at 23:35
  • LOL, I dig it! Enjoy the ride. :) Don't know if you encountered it along the way but this is an indispensable mapping for me (and many others) for jumping between buffers quickly: How to jump to buffer from ls? (the <leader>ls one). – B Layer Apr 12 '21 at 05:33

2 Answers2

2

Finally, I decided not to re-invent the wheel, and this problem seems to be more difficult than I think. So, I give Vem-Tabline a try and it works nicely, and the default settings of this plugin are good, so no need to put code into my .vimrc. Nice!

Now my MacVim looks like this, the prefix of buffer names are now skipped by default:

NeoZoom.lua
  • 1,442
  • 14
  • 31
  • That's cool. I use vim-airline and have it configured to show buffers in a similar way (I don't think it has tab display like that but I don't use them often enough to be bothered by it ;) – B Layer Apr 12 '21 at 05:37
  • 1
    I just randomly happened upon https://github.com/ryanoasis/vim-devicons today and I decided to try it out. As long as I am using a Nerd Font, file type icons show up automatically in the vim-airline tabline. So if you want icons and don't mind using plugins, that's one way to do it. (And vim-airline is great.) – B Layer Apr 13 '21 at 18:12
0

For Neovim users, I now recommend trying this tabline plugin: https://github.com/nanozuki/tabby.nvim:

  • The author follows the good practice "tabline" is for Vim's tabpages, not buffers.
  • It does support customization on tabpage names.
NeoZoom.lua
  • 1,442
  • 14
  • 31