Sitelet https://github.com/zachyarbrough/anchor.nvim
Skip to content

Latest commit

 

History

79 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚓ anchor.nvim ⚓

Lua Neovim

Installation • Usage • Configuration • Commands

anchor-demo


Harpoon for Directories! Anchor lets you bookmark directories instead of files, making it easy to jump between related repositories, notes, dotfiles, and more using your favorite fuzzy finder.

Installation

Tip

Run :checkhealth anchor after installation to ensure that the plugin has loaded correctly.

vim.pack (Neovim 0.12+)
vim.pack.add({ src = 'https://github.com/zachyarbrough/anchor.nvim' })
lazy.nvim
require('lazy').setup({
  {
      'zachyarbrough/anchor.nvim',
      opts = {},
  }
})
packer
require('packer').startup(function()
  use({
    'zachyarbrough/anchor.nvim',
    config = function()
      require('anchor').setup()
    end,
  })
end)
paq
require('paq')({
  { 'zachyarbrough/anchor.nvim' },
})
vim-plug
Plug 'zachyarbrough/anchor.nvim'

Usage

The following keymaps provide a good starting point. Feel free to customize them to fit your workflow.

local function anchor()
    return require('anchor')
end

vim.keymap.set('n', '<leader>aa', function() anchor().add() end, { desc = 'Add a directory to the anchor list' })
vim.keymap.set('n', '<leader>ad', function() anchor().delete() end, { desc = 'Delete a directory from the anchor list' })
vim.keymap.set('n', '<leader>al', function() anchor().toggle_list() end, { desc = 'Open anchor list in a floating buffer' })
vim.keymap.set('n', '<leader>a0', function() anchor().return_to_cwd() end, { desc = 'Return back to cwd' })

vim.keymap.set('n', '<leader>a1', function() anchor().open(1) end, { desc = 'Open fuzzy finder for anchor 1' })
...
vim.keymap.set('n', '<leader>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)

vim.keymap.set('n', '<leader>ag1', function() anchor().grep(1) end, { desc = 'Open fuzzy finder with live grep for anchor 1' })
...
vim.keymap.set('n', '<leader>ag5', function() anchor().grep(5) end, { desc = 'Open fuzzy finder with live grep for anchor 5' })

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.

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

    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.

About

Project-specific bookmarks for instantly fuzzy searching directories. Inspired by Harpoon.

Topics

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages