https://github.com/zachyarbrough/anchor.nvim
Anchor directories to your project for quick access. Inspired by Harpoon.
https://github.com/zachyarbrough/anchor.nvim
lua neovim neovim-plugin nvim nvim-plugin
Last synced: 4 days ago
JSON representation
Anchor directories to your project for quick access. Inspired by Harpoon.
- Host: GitHub
- URL: https://github.com/zachyarbrough/anchor.nvim
- Owner: zachyarbrough
- License: mit
- Created: 2026-06-18T22:12:10.000Z (11 days ago)
- Default Branch: main
- Last Pushed: 2026-06-19T02:59:36.000Z (11 days ago)
- Last Synced: 2026-06-19T03:16:20.255Z (11 days ago)
- Topics: lua, neovim, neovim-plugin, nvim, nvim-plugin
- Language: Lua
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - zachyarbrough/anchor.nvim - Pin project-specific directories for instant fuzzy searching. Inspired by Harpoon. (Project / Markdown and LaTeX)
README
:anchor: anchor.nvim :anchor:
[](http://www.lua.org)
[](https://neovim.io)
[Installation](#installation) • [Usage](#usage) • [Configuration](#configuration) • [Commands](#commands)

\
Pin project-specific directories and navigate them with your fuzzy finder. Perfect for jumping between notes, related repos, or git worktrees without losing context.
## Installation
> [!TIP]
> Run `:checkhealth anchor` after installation to ensure that the plugin has loaded correctly.
vim.pack (Neovim 0.12+)
```lua
vim.pack.add({ src = 'https://github.com/zachyarbrough/anchor.nvim' })
```
lazy.nvim
```lua
require('lazy').setup({
{
'zachyarbrough/anchor.nvim',
opts = {},
}
})
```
packer
```lua
require('packer').startup(function()
use({
'zachyarbrough/anchor.nvim',
config = function()
require('anchor').setup()
end,
})
end)
```
paq
```lua
require('paq')({
{ 'zachyarbrough/anchor.nvim' },
})
```
vim-plug
```lua
Plug 'zachyarbrough/anchor.nvim'
```
## Usage
The following keymaps provide a good starting point. Feel free to customize them to fit your workflow.
```lua
local function anchor()
return require('anchor')
end
vim.keymap.set('n', 'aa', function() anchor().add() end, { desc = 'Add a directory to the anchor list' })
vim.keymap.set('n', 'ad', function() anchor().delete() end, { desc = 'Delete a directory from the anchor list' })
vim.keymap.set('n', 'al', function() anchor().toggle_list() end, { desc = 'Open anchor list in a floating buffer' })
vim.keymap.set('n', 'a0', function() anchor().return_to_cwd() end, { desc = 'Return back to cwd' })
vim.keymap.set('n', 'a1', function() anchor().open(1) end, { desc = 'Open fuzzy finder for anchor 1' })
...
vim.keymap.set('n', 'a5', function() anchor().open(5) end, { desc = 'Open fuzzy finder for anchor 5' })
```
If the selected picker supports grepping files, you can live grep the anchored directory with the below keymaps. (Currently supports `fzf-lua`, `telescope`, `mini.picks`, and `snacks.picker`)
```lua
vim.keymap.set('n', 'ag1', function() anchor().grep(1) end, { desc = 'Open fuzzy finder with live grep for anchor 1' })
...
vim.keymap.set('n', 'ag5', function() anchor().grep(5) end, { desc = 'Open fuzzy finder with live grep for anchor 5' })
```
If you use git worktrees, Anchor includes a dedicated worktree picker so you can quickly search other worktrees.
```lua
vim.keymap.set('n', 'gw', function() anchor().toggle_worktrees() end, { desc = 'Open git worktrees in a floating buffer' })
```
## Configuration
>[!NOTE]
> `exclude_dirs` and `extended_excluded_dirs` only work for fuzzy finders, if `picker` is set to 'oil' or 'default' then these options will be ignored.
```lua
require('anchor').setup({
-- UI options for anchor list buffer
winopts = {
width = 80,
height = 15,
border = 'rounded',
title = 'Anchor',
numbers = 'absolute' -- 'absolute', 'relative', 'none'
},
-- UI options for fuzzy finder (currently only supported by fzf-lua and telescope)
picker_opts = {
grep = {}, -- UI Options for live grep
files = {} -- UI Options for file search
},
picker = 'auto', -- 'fzf-lua', 'telescope', 'default' (netrw), 'oil', 'mini', 'snack' or 'auto'
relative_paths = true, -- Display relative paths in the anchor list
show_branches = true, -- Show branch names when viewing git worktrees
excluded_dirs = { '.git', '.cache' }, -- Directories to exclude in fuzzy finder search
extended_excluded_dirs = { }, -- User specific directories to exclude in fuzzy finder search
})
```
## Commands
| Command | Description |
|---------|-------------|
| `:Anchor add` | Add a directory to the anchor list. |
| `:Anchor delete` | Remove a directory from the anchor list. |
| `:Anchor list` | Open the anchor list in a floating buffer. |
| `:Anchor open 0` | Return to the working cwd. |
| `:Anchor open {1-9}` | Open the fuzzy finder to navigate anchored directories at slots 1–9. (e.g. :`Anchor open 3`) |
| `:Anchor grep {1-9}` | Open the fuzzy finder with live grep to search through anchored directories at slots 1–9. (e.g. :`Anchor grep 3`) Currently only supported by fzf-lua and telescope. |
| `:Anchor worktrees` | Open the git worktrees picker. |