zefei / vim-wintabs

Modern buffer manager for Vim
MIT License
325 stars 25 forks source link

Add powerline font support #19

Closed kafendt closed 6 years ago

kafendt commented 6 years ago

Hey there, first of all I want to say thank you very much for this awesome plugin. It is in my opinion definitely the best tabs/buffer handling plugin out there :smile:. The only feature that was missing for me personally was support for powerline font, which I have tried to add. My changes add the following variables:

  1. g:wintabs_use_powerline This sets whether powerline fonts are used at all, if this is set to 0 nothing changes and the plugin will behave as it always has.

  2. g:wintabs_ui_powerline_sep_active_buffer_left Defines the seperator symbol on the left side of the currently active buffer.

  3. g:wintabs_ui_powerline_sep_active_buffer_right Defines the seperator symbol on the right side of the currently active buffer.

  4. g:wintabs_ui_powerline_sep_inbetween_buffer Defines the seperator symbol that will be shown inbetween buffers.

  5. g:wintabs_ui_powerline_sep_rightmost_buffer Defines the seperator symbol that will be at the far right of the buffer list.

  6. g:wintabs_ui_powerline_sep_active_tab_left Defines the seperator symbol on the left of the currently active tab.

  7. g:wintabs_ui_powerline_sep_active_tab_right Defines the seperator symbol on the left of the currently active tab.

  8. g:wintabs_ui_powerline_sep_inbetween_tab Defines the seperator symbol that will be shown inbetween tabs.

  9. g:wintabs_ui_powerline_sep_leftmost_tab Defines the seperator symbol that will be at the far left of the tabs list.

  10. g:wintabs_ui_active_buffer_higroup The highlight group for the currently active buffer. (e.g. : g:wintabs_ui_active_buffer_higroup='WintabsActiveBuffer' with hi! WintabsActiveBuffer cterm=NONE ctermbg=1 ctermfg=8 guibg=#009933 guifg=#000000)

  11. g:wintabs_ui_active_buffer_changed_higroup The highlight group for the currently active buffer when there are unsaved changes.

12.g:wintabs_ui_inactive_buffer_higroup The highlight group for currently inactive buffers. (e.g. g:wintabs_ui_inactive_buffer_higroup='WintabsInactiveBuffer' with let s:linenr_bg_color = synIDattr(synIDtrans(hlID('LineNr')), 'bg', "gui") let s:linenr_fg_color = synIDattr(synIDtrans(hlID('LineNr')), 'fg', "gui") execute 'hi! WintabsInactiveBuffer cterm=NONE ctermbg=1 ctermfg=8 guibg='.s:linenr_bg_color.' guifg='.s:linenr_fg_color

Here is my current setup: let g:wintabs_use_powerline = 1 let g:wintabs_ui_powerline_sep_active_buffer_left = "\ue0b4" let g:wintabs_ui_powerline_sep_active_buffer_right = "\ue0b4" let g:wintabs_ui_powerline_sep_inbetween_buffer = "\ue0b5" let g:wintabs_ui_powerline_sep_rightmost_buffer = "\ue0b4" let g:wintabs_ui_active_buffer_higroup = "WintabsActiveBuffer" let g:wintabs_ui_active_buffer_changed_higroup = "WintabsActiveBufferChanged" let g:wintabs_ui_inactive_buffer_higroup = "WintabsInactiveBuffer" let g:wintabs_ui_active_tab_higroup = "WintabsActiveTab" let g:wintabs_ui_inactive_tab_higroup = "WintabsInactiveTab" let g:wintabs_ui_show_vimtab_name = 2 colorscheme solarized (its important that the higroups are declared after this) let s:linenr_bg_color = synIDattr(synIDtrans(hlID('LineNr')), 'bg', "gui") let s:linenr_fg_color = synIDattr(synIDtrans(hlID('LineNr')), 'fg', "gui") execute 'hi! WintabsInactiveBuffer cterm=NONE ctermbg=1 ctermfg=8 guibg='.s:linenr_bg_color.' guifg='.s:linenr_fg_color hi! WintabsActiveBuffer cterm=NONE ctermbg=1 ctermfg=8 guibg=#009933 guifg=#000000 hi! WintabsActiveBufferChanged cterm=NONE ctermbg=1 ctermfg=8 guibg=#f2b81e guifg=#000000 hi! WintabsActiveTab cterm=NONE ctermbg=1 ctermfg=8 guibg=#FFFFFF guifg=#000000 hi! WintabsInactiveTab cterm=NONE ctermbg=1 ctermfg=8 guibg=#073642 guifg=#586e75

Which ends up to look like this for an unmodified buffer: screenshot from 2017-09-25 21 51 00

And this for a modified buffer: screenshot from 2017-09-25 21 53 49

A different possible look: screenshot from 2017-09-26 10 42 32

There are a couple of problems still:

  1. The seperators break when .vimrc is reloaded from within vim, a restart fixes this, but this should definitly be fixed
  2. I haven't been able to get the truncation of the bufferline to work yet
  3. Doesn't work with the 'taboo' plugin
  4. Haven't implemented it for statusline option yet

I guess its not really in a mergable state right now but if you are interested in this feature I would try to fix the problems that still exist and add my changes to the docs. Just let me know what you think.

zefei commented 6 years ago

Hey @kafendt,

Thank you for the PR. This looks like a really good addition and I would certainly like to have it in wintabs. Unfortunately like you said, currently this isn't in a mergable state. When I wrote wintabs, powerline/airline support was on my roadmap, but the huge complexity it brings to the tabs layout made me drop it. The main challenges for supporting this feature are:

Currently I don't have short term plans to add multi-byte character support to wintabs, but I may do it whenever I find opportunity. If you want to continue to evolve this PR, I'd suggest tackling another issue first: to allow separator or tab name to be multi-byte unicode. It's more clear how to test the correctness of that issue (total length of tabs is calculated correctly), and it's trivial to extend it to support powerline once its correctness is guaranteed.

To make this PR mergable, I'd like to have:

Again, thank you very much for putting time on this!

kafendt commented 6 years ago

Hey sorry for the late reply, I am pretty busy at the moment. I agree with you, I mainly created the pull request to see whether there was interest in the feature at all. Now that I know there is I'll try to implement what you mentioned. It might take me a while though because I am currently still busy with a few other things, I will get back to you as soon as I am working on it again!

Thanks @zefei !

zefei commented 6 years ago

Hey @kafendt,

I did find opportunity to work on this issue lately, and I rewrote the renderer and layout functions to support multibyte characters. With the new renderer API (g:wintabs_renderers), your changes could be easily adopted to render powerline characters correctly.

I plan to move powerline support or other renderer features into separate plugins, so that the core wintabs options are not too many. Do you want to make your repo vim-wintabs-powerline standalone and containing only renderer functions? I can do that as well since I do plan to revamp wintabs a bit next month (will include your code, neovim mouse support, a few more utility commands).

Thanks!

kafendt commented 6 years ago

Hey there, thats awesome I'd be happy to implement the changes. So, as I take it you want to have plugins to your plugin, right? My repo would then only contain functions that extend the base vim-wintabs, is that what you're going for? I could probably work on this again within the next month. If you'd prefer to keep all elements under one roof (your github account) that'd be fine by me too. Just let me know you plans :smiley:.

zefei commented 6 years ago

Hey @kafendt,

Yeah that's what I meant. I don't really need all repos under this account, but I'll probably still create another repo here, since I do want to make sure it reflects some basic designs of wintabs - having simple defaults that work with default highlight groups such as Tabline, TablineSel, etc. And leave further customizations to pull requests.

If I don't have time to do that within the next month, you can surely create the repo, and I'll change the doc and README to link to that.

zefei commented 6 years ago

@kafendt,

I've pushed a v0 for powerline font support in this repo: https://github.com/zefei/vim-wintabs-powerline. I haven't got enough time to put in docs or fully test it, but it should be functional enough. Let me know if you have any suggestions. Thanks!

jordwalke commented 6 years ago

This seems like a great feature!

zefei commented 6 years ago

This feature is now fully supported in vim-wintabs-powerline, so closing this PR. Thank you @kafendt for the work you did here!