elihunter173 / dirbuf.nvim

A file manager for Neovim which lets you edit your filesystem like you edit text
GNU Affero General Public License v3.0
426 stars 6 forks source link

Feature: Ability to pass an `on_attach` function to set custom `dirbuf` buffer keymaps #38

Closed sanka047 closed 2 years ago

sanka047 commented 2 years ago

Instead of relying on autocmds, it would be nice to be able to setup custom keymaps using a hook that is always run once the dirbuf buffer is created. This is a nice-to-have and not completely necessary since we can use autocmds to do the same thing. Just curious if there would be interest in making this change.

elihunter173 commented 2 years ago

I'm personally not interested in this change.

Since all directory buffers have their filetype set to dirbuf, imo it's cleaner and more understandable to use ftplugin files or FileType autocmds to do this kind of user-configuration. And since you can emulate the behavior of on_attach pretty easily, I'd rather avoid the extra configuration option.

vim.api.nvim_create_autocmd("FileType", {
  pattern = "dirbuf",
  callback = my_on_attach,
})
sanka047 commented 2 years ago

That’s fair. I only mentioned since I figured it would be an easy change to make within the plugin since you already have an ftplugin that creates mappings where you could just toss in a call to the hook without much change.

Admittedly, I haven’t been using custom ftplugins so it didn’t cross my mind. I’ll take a deeper look into setting those up for some of my configuration. Thanks!