Skip to content

A lightweight Neovim plugin to copy file references with line numbers to your clipboard. Great for sharing exact code locations with your friendly neighbourhood AI code agent.

License

Notifications You must be signed in to change notification settings

cajames/copy-reference.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

copy-reference.nvim

A simple Neovim plugin to copy file references with optional line numbers to your clipboard.

nvim-reference

Features

  • 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)

Installation

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" },
  },
}

Configuration

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
}

Usage

  • yr - Copy the current file path
  • yrr - Copy the current file path with line number
  • Visual mode + yrr - Copy file path with line range

Commands

  • :CopyReference - Copy file:line reference (default)
  • :CopyReference line - Copy file:line reference
  • :CopyReference file - Copy file path only

License

MIT

About

A lightweight Neovim plugin to copy file references with line numbers to your clipboard. Great for sharing exact code locations with your friendly neighbourhood AI code agent.

Topics

Resources

License

Stars

Watchers

Forks

Languages