Skip to content

laoz40/git-worktree.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

git-worktree.nvim

Made my own plugin to create and switch between git worktrees. Uses snacks.nvim picker. Auto installs packages when a lockfile is found.

Inspired by ThePrimagen's git-worktree.vim, just wanted to make my own.

Installation

vim.pack.add({
	{ src = "https://github.com/laoz40/git-worktree.nvim" },
})

require("git-worktree").setup({
	auto_install = true,
})

Setup

Option Default Description
auto_install true Automatically run package install after creating a worktree when a lockfile is found.

Supported lockfiles:

  • package-lock.jsonnpm install
  • pnpm-lock.yamlpnpm install
  • yarn.lockyarn install
  • bun.lock / bun.lockbbun install

Snacks picker source

The worktree picker uses the source name git_worktrees, so you can configure its layout like:

require("snacks").setup({
	picker = {
		sources = {
			git_worktrees = { layout = "vscode" },
		},
	},
})

Usage

Commands:

:GitWorktreeSwitch
:GitWorktreeCreate

Lua API:

require("git-worktree").switch()
require("git-worktree").create()

Example keymaps:

vim.keymap.set("n", "<leader>gw", function()
	require("git-worktree").switch()
end, { desc = "Git worktree switch" })

vim.keymap.set("n", "<leader>gW", function()
	require("git-worktree").create()
end, { desc = "Git worktree create" })

About

Neovim plugin to create and switch between git worktrees using snacks.nvim picker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages