smilhey / cabinet.nvim

Cabinet is a plugin for Neovim that allows you to manage your buffers in drawers.
MIT License
23 stars 2 forks source link

new drawer puts nvim cwd into home dir #3

Closed unphased closed 5 months ago

unphased commented 7 months ago

This is bad for me personally because my telescope file selector chokes on my home dir because it's got too many files. Yeah I have to replace 'nvim-telescope/telescope-fzf-native.nvim' with actual real fzf at some point, so that I won't continue to suffer these silly I/O issues, but... I don't think it makes sense to default to home dir with a new drawer. It should default to the pwd launched by nvim. I think this would be a good refinement of the feature set, because once you change vim's directory it is changed from that point so if we intentionally have cabinet remember the starting dir then that will make it even more powerful.

smilhey commented 7 months ago

Yeah, I get your usage but I don't thing changing the default solves the issue as other people would prefer other thing (go back one level for example ...).

However I could add the directory at the time of leaving to the DrawNewEnter event so that you can cd into the directory on entering the new drawer. You'd need to add this autocmd

        vim.api.nvim_create_autocmd("User", {
            nested = true,
            pattern = "DrawNewEnter",
            callback = function(event)
                previous_directory = event.previous.cwd
                                vim.cmd('cd ' .. previous_directory)
            end,
        })

What do you think about it ?

smilhey commented 5 months ago

The default has been updated