Add `update_on_worktree_change` config option, and depreacte `update_on_change_command`
This pull request allows for more control over what happens when the current working directory is changed to the specified worktree. A workaround was mentioned in #13 , but it isn't ideal since git-worktree would always run the code to open the current buffer in the specified worktree. With the changes in this PR, the workaround can be achieved without running unnecessary code.
No breaking changes are introduced, and users won't experience any different behavior with their current configs. But the assumption was made that this would lead to the eventual deprecation of on_change_command. This can be discussed, because I don't feel strongly about it.
I use auto-session for managing sessions, but any session-manager/code can be used here. A sample configuration is below.
local worktree = require("git-worktree")
local update_on_worktree_change = function(op, metadata)
vim.api.nvim_command("RestoreSession")
end
require("git-worktree").setup({
clear_jumps_on_change = false, -- this is handled by auto-session
update_on_worktree_change = update_on_worktree_change,
})