Skip to content

mzner/tak.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

tak.nvim

Switch between git worktrees from inside Neovim — fuzzy-find, jump in, keep coding.

tak.nvim is the Neovim companion for tak, a CLI for managing git worktrees. If you already use tak in the terminal, this lets you do the same thing without leaving the editor: a fuzzy picker over your worktrees that :cds into the one you choose.

Why

If you've ever:

  • Stashed work to switch branches just to fix one quick thing
  • Opened a second terminal tab to look at main while staying on your feature branch
  • Lost flow rebuilding mental context after git checkout

…worktrees fix that — one branch per directory, no stashing — and tak.nvim makes hopping between them as fast as opening a file.

Features

  • :Tak — fuzzy-find a worktree and :cd Neovim into it.
  • :TakAdd [branch] — create a new worktree with tak add, then jump in.
  • Works with what you have. Auto-detects fzf-lua or telescope.nvim. With neither installed, falls back to Neovim's built-in vim.ui.select.
  • Default keymaps<leader>tw (pick) and <leader>ta (add).
  • Pinned worktrees are marked with 📌 in the picker.
  • Lightweight — under 300 lines of Lua. The plugin shells out to the tak CLI for everything; the CLI stays the source of truth.

Requirements

  • Neovim 0.10+ (uses vim.system, vim.json)
  • tak on $PATH
  • Optional, recommended: fzf-lua or telescope.nvim for a proper fuzzy picker

Installation

LazyVim / lazy.nvim

Drop this in ~/.config/nvim/lua/plugins/tak.lua:

return {
  "mzner/tak.nvim",
  -- Optional: declare your fuzzy finder so it loads first
  -- dependencies = { "ibhagwan/fzf-lua" },
  -- dependencies = { "nvim-telescope/telescope.nvim" },
  cmd = { "Tak", "TakAdd" },
  keys = {
    { "<leader>tw", "<cmd>Tak<cr>",    desc = "Pick worktree" },
    { "<leader>ta", "<cmd>TakAdd<cr>", desc = "Add worktree" },
  },
  opts = {},
}

That's it. Restart Neovim and hit <leader>tw from any tak-enabled repo.

packer.nvim

use {
  "mzner/tak.nvim",
  config = function() require("tak").setup() end,
}

Local development

If you're hacking on the plugin locally:

return {
  "mzner/tak.nvim",
  dir = "~/projects/tak.nvim",
  cmd = { "Tak", "TakAdd" },
  opts = {},
}

Usage

Trigger What it does
<leader>tw or :Tak Open the worktree picker. <CR> cds into the selected worktree.
<leader>ta or :TakAdd Prompt for a branch name, run tak add, then open the picker.
:TakAdd feature/foo Non-interactive: create feature/foo directly.

The picker shows every worktree in the current repo. Pinned ones (tak pin) are tagged with 📌. Selecting an entry runs tak cd <branch> and changes Neovim's working directory — so file pickers, terminals, LSP root detection, and :cd-aware plugins all see the new location.

Configuration

All options shown with defaults:

require("tak").setup({
  keymaps = {
    pick = "<leader>tw",   -- :Tak
    add  = "<leader>ta",   -- :TakAdd
  },
  -- keymaps = false,      -- disable all default keymaps
})

Forcing a picker backend

The plugin auto-detects fzf-lua → telescope.nvim → vim.ui.select. Override:

vim.g.tak_picker = "telescope"  -- or "fzf" or "ui"

How does it work?

The plugin doesn't reimplement anything from tak — it shells out:

  • :Tak reads tak ls --json and renders the entries in the picker. Each entry already has its path, so selecting one just runs :cd directly.
  • :TakAdd runs tak add <branch> and re-opens the picker.

That's why this plugin can stay tiny: the heavy lifting (config, git, paths, state) all lives in the CLI. If tak learns a new trick, the plugin doesn't need to.

Troubleshooting

tak: command not found — install tak and confirm it's on $PATH from the shell Neovim was launched from.

Picker is empty — you're not inside a tak-enabled repo, or the repo has no worktrees yet. Run tak init then tak add <branch> from the terminal.

Edits to plugin files don't take effectrequire() caches modules. Run :Lazy reload tak.nvim or restart Neovim.

License

MIT

About

Neovim companion for tak

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages