akinsho / bufferline.nvim

A snazzy bufferline for Neovim
GNU General Public License v3.0
3.52k stars 198 forks source link

[Bug]: Disabling mouse commands is unintuitive due to vim.tbl_deep_extend() #705

Closed durka closed 1 year ago

durka commented 1 year ago

Is there an existing issue for this?

What happened?

I wanted to disable the right mouse click action.

Because the user-provided config is merged with the defaults, setting an option to nil has no effect. For example

require("bufferline").setup{ config = { right_mouse_command = nil }}

This surprisingly (from a user perspective) does not actually disable the right mouse command, because the merge uses the default value which is not nil.

A workaround is to set the command to '' instead of nil.

I'm not sure there is any solution, maybe just a note in the documentation that putting a nil in the config will have no effect and to use '' instead in this situation.

What did you expect to happen?

Since I saw

right_mouse_command = 'bdelete! %',
middle_mouse_command = nil,

in the default options, I thought I could simply swap the values to switch the commands. But I had to replace nil with '' as explained above.

Config

require("bufferline").setup{ config = { right_mouse_command = nil }}

Additional Information

No response

commit

No response

akinsho commented 1 year ago

Yeah in the case of user configurations setting things to nil is unfortunately not a good way to indicate that it isn't wanted for the reason specified above. You can also use false as a value to prevent the command being run. I've added a note to the docs on the dev branch