The nvim-agent-path-ref plugin provides
- a command for yanking
@-style file references — the syntax understood by AI coding agents such as Claude Code — straight from Neovim to your system clipboard; - support for line ranges, yanked from a visual selection or an explicit command range;
- a
<Plug>mapping for binding all of this to a single key.
@lua/config/options.lua whole file
@src/app.js#L12 single line
@src/app.js#L12-15 line range
Note
References are resolved against Neovim's current working directory, so they work when pasted into an agent session started from the same directory. Files outside it fall back to their absolute path.
- Neovim 0.10 or later
You can install nvim-agent-path-ref with your favorite package manager (or using the native package feature of vim, see :h packages); e.g., using the following spec with lazy.nvim:
{
"KaySum/nvim-agent-path-ref",
keys = {
{ "<leader>ay", "<Plug>(AgentPathRef)", mode = { "n", "x" }, desc = "Yank @file reference" },
},
}or with vim-plug:
Plug 'KaySum/nvim-agent-path-ref'nvim-agent-path-ref needs no configuration and has no setup function. No mappings are created by default; bind <Plug>(AgentPathRef) to a key of your choice — it works in both normal and visual mode:
vim.keymap.set({ "n", "x" }, "<leader>ay", "<Plug>(AgentPathRef)", { desc = "Yank @file reference" })| Trigger | Copies |
|---|---|
:AgentPathRef |
@path/to/file.lua |
:AgentPathRef on a visual selection |
@path/to/file.lua#L12-15 |
:12,15AgentPathRef |
@path/to/file.lua#L12-15 |
The reference is written to the + (system clipboard) register.
Check :h nvim-agent-path-ref for the full documentation.