https://github.com/elliotxx/copypath.nvim
Copy path with line number, supporting both local paths and repository URLs.
https://github.com/elliotxx/copypath.nvim
neovim-plugin
Last synced: 10 days ago
JSON representation
Copy path with line number, supporting both local paths and repository URLs.
- Host: GitHub
- URL: https://github.com/elliotxx/copypath.nvim
- Owner: elliotxx
- License: mit
- Created: 2024-12-31T10:12:06.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-01-08T03:49:10.000Z (9 months ago)
- Last Synced: 2025-04-07T03:22:21.212Z (6 months ago)
- Topics: neovim-plugin
- Language: Lua
- Homepage:
- Size: 10.7 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# copypath.nvim
A Neovim plugin that solves a common developer pain point: how to quickly share code locations with colleagues?
https://github.com/user-attachments/assets/9992cc69-28ca-49a2-9586-cdc3eb6c73cd
## Features
- Copy GitHub/GitLab URLs with line numbers when in a Git repo
```
https://github.com/user/repo/blob/main/file.lua#L42
```

- Fallback to relative path + line number outside Git repos
```
src/file.lua:42
```

- Automatic SSH/HTTPS URL conversion
```
git@host:org/repo => https://host/org/repo
```## Installation
Using [lazy.nvim](https://github.com/folke/lazy.nvim):
```lua
{ 'elliotxx/copypath.nvim' }
```Using [packer.nvim](https://github.com/wbthomason/packer.nvim):
```lua
use {
'elliotxx/copypath.nvim',
config = function()
require('copypath').setup({
-- Your custom config here
})
end
}
```## Configuration
```lua
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:
* Copy the web URL (e.g., https://github.com/user/repo/blob/main/file.lua#L42)
* Supports various Git platforms (GitHub, GitLab, etc.)
- 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