Gitlink.nvim
Goto/Copy File's Online Link
Install / Use
/learn @wsdjeg/Gitlink.nvimREADME
gitlink.nvim
A Lua plugin for Neovim to generate and open permalink of current file in browser or copy the link to clipboard.
<!-- vim-markdown-toc GFM -->- Features
- Requirements
- Installation
- Usage
- Configuration
- Supported Platforms
- Credits
- Self-Promotion
- License
Features
- 🚀 Generate permalink for current file at current line
- 📋 Copy link to clipboard
- 🌐 Open link directly in browser
- 🔍 Auto-detect Git platform from remote URL
- 🔗 Support both HTTPS and SSH remote URLs
Requirements
- Neovim >= 0.10.0
- Git
Installation
Using lazy.nvim
{
'wsdjeg/gitlink.nvim',
keys = {
{ '<leader>gy', function() require('gitlink').copy() end, desc = 'Copy git link' },
{ '<leader>gY', function() require('gitlink').open() end, desc = 'Open git link in browser' },
},
}
Using nvim-plug
require('plug').add({
{
'wsdjeg/gitlink.nvim',
},
})
Usage
-- Copy git link to clipboard
vim.keymap.set('n', '<leader>gy', function()
require('gitlink').copy()
end, { silent = true, desc = 'Copy git link' })
-- Open git link in browser
vim.keymap.set('n', '<leader>gY', function()
require('gitlink').open()
end, { silent = true, desc = 'Open git link in browser' })
| Function | Description |
| --------------------------- | --------------------------- |
| require('gitlink').copy() | Copy permalink to clipboard |
| require('gitlink').open() | Open permalink in browser |
Configuration
require('gitlink').setup()
Supported Platforms
| Platform | URL Format | Custom Domain Support |
| --------- | ------------------------------------------ | ------------------------------- |
| GitHub | {url}/blob/{commit}/{path}#L{line} | No |
| GitLab | {url}/-/blob/{commit}/{path}#L{line} | Yes (matches gitlab. pattern) |
| Bitbucket | {url}/src/{commit}/{path}#lines-{line} | No |
| Gitee | {url}/blob/{commit}/{path}#L{line} | No |
| Codeberg | {url}/src/commit/{commit}/{path}#L{line} | No |
Credits
Self-Promotion
Like this plugin? Star the repository on GitHub.
Love this plugin? Follow me on GitHub.
License
This project is licensed under the GPL-3.0 License.
