Skip to content

subsid/anchor.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

anchor.nvim

A simple, per-project file bookmarking plugin for Neovim. Open a project, mark the files you're working on, and jump between them instantly.

No frills. No dependencies beyond Neovim itself (telescope integration is optional). Marks persist across sessions, scoped to each project directory. Projects are determined by vim.loop.cwd() — the directory you opened Neovim in.

Inspired by harpoon and bookmarks.nvim.

Installation

lazy.nvim

{
  "subsid/anchor.nvim",
  lazy = false,
  dependencies = { "nvim-telescope/telescope.nvim" }, -- optional
  config = function()
    require("anchor").setup()
  end,
}

With keymaps

{
  "subsid/anchor.nvim",
  lazy = false,
  config = function()
    local anchor = require("anchor")
    anchor.setup()

    local map = vim.keymap.set
    map("n", "<leader>ja", anchor.add,          { desc = "Anchor: add file" })
    map("n", "<leader>jx", anchor.remove,       { desc = "Anchor: remove file" })
    map("n", "<leader>jo", anchor.toggle_menu,  { desc = "Anchor: open list" })
    map("n", "<leader>jt", anchor.open_telescope, { desc = "Anchor: telescope picker" })
    map("n", "<leader>jn", anchor.next,         { desc = "Anchor: next" })
    map("n", "<leader>jp", anchor.prev,         { desc = "Anchor: prev" })

    for i = 1, 9 do
      map("n", "<leader>" .. i, function() anchor.select(i) end,
        { desc = "Anchor: jump to #" .. i })
    end
  end,
}

Usage

Function Description
anchor.add() Add current file to the anchor list
anchor.remove() Remove current file from the list
anchor.select(n) Jump to anchor at position n
anchor.next() Cycle to the next anchor
anchor.prev() Cycle to the previous anchor
anchor.toggle_menu() Open an editable list of anchors
anchor.open_telescope() Browse anchors in a telescope picker

Editable menu

toggle_menu opens a floating window listing all anchors for the current project. You can reorder or delete lines, then :w to save. Press q or <Esc> to close without saving, <CR> to open the file under the cursor.

Telescope picker

open_telescope opens a telescope picker with file preview. Press <C-d> to delete an anchor from within the picker.

Configuration

Option Default Description
data_path ~/.local/share/nvim/anchor.json Path to the JSON file where anchors are stored

A "project" is simply the working directory when Neovim was opened (vim.loop.cwd()). Opening Neovim in a different directory gives you a separate, independent list.

Running tests

./run_tests.sh

Requires plenary.nvim to be installed at ~/.local/share/nvim/lazy/plenary.nvim.

About

Per-project file bookmarking plugin for Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors