A simple Neovim plugin to copy file references with optional line numbers to your clipboard.
- Copy file path with line number (
file.lua:42) - Copy just the file path (
file.lua) - Smart path detection (relative to git root or cwd)
- Visual mode support for line ranges (
file.lua:10-25)
Using lazy.nvim
{
"cajames/copy-reference.nvim",
opts = {}, -- optional configuration
keys = {
{ "yr", "<cmd>CopyReference file<cr>", mode = { "n", "v" }, desc = "Copy file path" },
{ "yrr", "<cmd>CopyReference line<cr>", mode = { "n", "v" }, desc = "Copy file:line reference" },
},
}The plugin works out of the box with sensible defaults:
{
register = "+", -- Clipboard register (+ for system clipboard)
use_git_root = true, -- Use git root for relative paths when in a git repo
}yr- Copy the current file pathyrr- Copy the current file path with line number- Visual mode +
yrr- Copy file path with line range
:CopyReference- Copy file:line reference (default):CopyReference line- Copy file:line reference:CopyReference file- Copy file path only
MIT
