romgrk / barbar.nvim

The neovim tabline plugin.
2.23k stars 83 forks source link

feat(bufferline): customize buffer close behavior #372

Closed Iron-E closed 1 year ago

Iron-E commented 1 year ago

Closes #368

About

In a previous request (issue #234, PR #270), it was asked that barbar.nvim mimic the behavior of a browser when closing buffers: choose the buffer to the right of the current buffer.

Code has been added to ensure that the behavior of :BufferClose and :BufferDelete never differs in the future, since they are supposed to be true synonyms.

Config

To access this feature, simply do:

require'bufferline'.setup {focus_on_close = 'left'} -- or 'right'

Todo


cc: @sarmong

Iron-E commented 1 year ago

@otavioschwanck @romgrk any opinions about what the option should be? Right now it is:

require'bufferline'.setup {on_close_behavior = 'left'}

…but I'm not a fan of that. The questions we should consider are:

  1. What should the name of the option be?
  2. What should the possible values be? e.g. 'left' & 'right', true & false`
    • If we use a string, it might be possible to specify 'first' or 'last' as the close behavior. I don't see the use case, but someone might want it.
    • On the other hand, a boolean feels more natural for something like mimic_browser_close

My words are failing me here. Input is appreciated!

otavioschwanck commented 1 year ago

@otavioschwanck @romgrk any opinions about what the option should be? Right now it is:

require'bufferline'.setup {on_close_behavior = 'left'}

…but I'm not a fan of that. The questions we should consider are:

  1. What should the name of the option be?
  2. What should the possible values be? e.g. 'left' & 'right', true & false`

    • If we use a string, it might be possible to specify 'first' or 'last' as the close behavior. I don't see the use case, but someone might want it.
    • On the other hand, a boolean feels more natural for something like mimic_browser_close

My words are failing me here. Input is appreciated!

1/2. close_focus_left: true|false. focus_on_close: left|right

And i think the focus on left should be default (is vscode, atom, jetbrains default behaviour)

Iron-E commented 1 year ago

I think focus_on_close is what I'll go with for now. Thanks for the feedback

Iron-E commented 1 year ago

@otavioschwanck I've implemented the 'left' & 'right' distinctions. I'm leaving this PR as a draft for now just because it needs some testing, and I'm waiting to see what @romgrk thinks of the option naming scheme.

Iron-E commented 1 year ago

Glad to hear it's working. I'll wait to change the default behavior until hearing from @romgrk, but FWIW seeing as other editors (not browsers) use focus_on_close = 'left' I am inclined to agree with you.

(Note: I still have to document the option, but that won't matter for further discussion)

otavioschwanck commented 1 year ago

@otavioschwanck I've implemented the 'left' & 'right' distinctions. I'm leaving this PR as a draft for now just because it needs some testing, and I'm waiting to see what @romgrk thinks of the option naming scheme.

@romgrk important here: Tested 4 editors: VSCode, helix, RubyMine and atom, every editor use the focus_on_close = 'left'

Iron-E commented 1 year ago

Since he seems a little busy right now, I'll go ahead and set the default since I noticed he gave his opinion before.

Once I add the docs for this option, I'll merge it.

sarmong commented 1 year ago

Thanks for implementing this!