Skip to content

Copy path with line number, supporting both local paths and repository URLs.

License

Notifications You must be signed in to change notification settings

elliotxx/copypath.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

copypath.nvim

copypath.nvim

A Neovim plugin that solves a common developer pain point: how to quickly share code locations with colleagues?

copypath-demo.mp4

Features

  • Copy GitHub/GitLab URLs with line numbers when in a Git repo
    https://github.com/user/repo/blob/main/file.lua#L42
    
    image
  • Fallback to relative path + line number outside Git repos
    src/file.lua:42
    
    image
  • Automatic SSH/HTTPS URL conversion
    git@host:org/repo => https://host/org/repo
    

Installation

Using lazy.nvim:

{ 'elliotxx/copypath.nvim' }

Using packer.nvim:

use {
    'elliotxx/copypath.nvim',
    config = function()
        require('copypath').setup({
            -- Your custom config here
        })
    end
}

Configuration

require('copypath').setup({
    -- Default options
    default_mappings = true,  -- Set to false to disable default mappings
    mapping = 'Y',            -- Default mapping to trigger copy
    notify = true,            -- Show notification when path is copied
})

Usage

By default, pressing Y in normal mode will:

  • If in a git repository:
  • If not in a git repository:
    • Copy the relative path with line number (e.g., src/file.lua:42)
    • Falls back to absolute path if relative path is not available

License

MIT

About

Copy path with line number, supporting both local paths and repository URLs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages