This is a simple extension to list, select, add, remove and move git-worktrees, inspired by git-worktree.nvim.
{ log_level = "info", backend = "telescope", on_select = nil, on_add = nil, }Installation for Telescope (lazy.nvim)
return { "https://github.com/rbmarliere/gitree.nvim", dependencies = { "nvim-lua/plenary.nvim", { "nvim-telescope/telescope.nvim", branch = "0.1.x" }, }, keys = { { "<Leader>gw", function() require("telescope").extensions.gitree.list() end, desc = "List worktrees", }, { "<Leader>gW", function() require("telescope").extensions.gitree.list(vim.fn.expand("%:.")) end, desc = "Open current file in another worktree", }, }, init = function() require("telescope").setup({ extensions = { gitree = { on_add = function() vim.system({ "git", "submodule", "update", "--init", "--recursive" }) end, }, }, }) require("telescope").load_extension("gitree") end, }Installation for Snacks (lazy.nvim)
return { "https://github.com/rbmarliere/gitree.nvim", dependencies = { "nvim-lua/plenary.nvim", "folke/snacks.nvim", }, keys = { { "<Leader>gw", function() require("gitree.picker.snacks").list() end, desc = "List worktrees", }, { "<Leader>gW", function() require("gitree.picker.snacks").list(vim.fn.expand("%:.")) end, desc = "Open current file in another worktree", }, }, opts = { backend = "snacks", on_add = function() vim.system({ "git", "submodule", "update", "--init", "--recursive" }) end, } }
After opening the list() picker, use the default action key maps:
<CR>
-> Select a worktree
<M-a>
-> Add a worktree
<M-r>
-> Remove the worktree under the cursor
<M-m>
-> Move the worktree under the cursor
<M-g>
-> Grep in the worktree under the cursor
<M-p>
-> Find files in the worktree under the cursor
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4