-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(tabs): only show close icon if multiple tabse #646
refactor(tabs): only show close icon if multiple tabse #646
Conversation
@dwijesinghe this is a good idea, thanks for the PR. I had been considering something similar, but hadn't gotten round to implementing it. The only suggestion I have would be to make this behaviour the default also I'd go as far as to remove the option tbh since frankly it's useless to have a button that does nothing and I get issues from users who are confused that the button "does not work" when there is only one tab open. I'd say just change this to be the only behaviour, i.e. only show the button if there is a tab. |
lua/bufferline/ui.lua
Outdated
) | ||
if (vim.api.nvim_eval('tabpagenr("$")') > 1 or options.always_show_tab_close_icon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to use this sort of api e.g. nvim_eval.
You can do
if #vim.api.nvim_list_tabpages() > 1 or ... then
...
Tbh I think this would be better to add this to the tab close button function so that it returns an empty component if there is only a single tab
doc/bufferline.txt
Outdated
@@ -150,6 +150,7 @@ The available configuration are: | |||
sort_by = 'insert_after_current' |'insert_at_end' | 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) | |||
-- add custom logic | |||
return buffer_a.modified > buffer_b.modified | |||
always_show_tab_close_icon = true | false, -- if false the tab close icon will only appear if there is more than one tab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say don't make this optional at all, I made a mistake by offering too many things as options. I'd say to just be decisive and make this the only behaviour since the alternative is useless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a couple of comments re. the implementation but definitely like this idea
…se icon an empty component instead of omitting it entirely
@akinsho Thanks! Just made those changes, its def a lot more succinct now. Let me know if there's anything else you want modified etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
always_show_tab_close_icon
option
The tab close icon can look a little odd (and won't do anything) if there's only one tab in use. See this reddit post
Since I would guess many people who use this plugin would be less inclined to use standard vim tabs - I thought it would make sense and improve aesthetics to remove it if there's only one tab in use (it will reappear if the user opens another tab). For those who want to always see the tab close icon, the
always_show_tab_close_icon
option can be set totrue
in setup (default isfalse
).Please let me know your thought and btw I love this plugin :)