gitlink.nvim is a lightweight Neovim plugin that generates permalink
to the current file and line in your Git repository.
It auto-detects the Git hosting platform from your remote URL,
builds the correct permalink format, and lets you copy it to clipboard
or open it directly in the browser.
Whether you are on GitHub, GitLab, Bitbucket, Gitee, Codeberg, Gitea,
Sourcehut, or GitCode, gitlink.nvim has you covered.
- ✨ Features
- 📦 Installation
- 🔧 Configuration
- ⚙️ Usage
- 🌐 Supported Platforms
- 📣 Self-Promotion
- 💬 Feedback
- 🙏 Credits
- 📄 License
- Generate permalink for current file at current line
- Copy link to clipboard or open directly in browser
- Auto-detect Git platform from remote URL
- Support both HTTPS and SSH remote URLs
- Support line range links (select lines in visual mode)
- Support self-hosted instances (GitLab, Gitea)
gitlink.nvim works with all major Neovim plugin managers. Neovim 0.10+ and Git are required.
-
Using nvim-plug
require('plug').add({ { 'wsdjeg/gitlink.nvim', }, })
-
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 packer.nvim
use({ 'wsdjeg/gitlink.nvim', })
-
Using luarocks
luarocks install gitlink.nvim
require('gitlink').setup()-- Copy git link to clipboard (normal mode: current line, visual mode: selected range)
vim.keymap.set({ 'n', 'x' }, '<leader>gy', function()
require('gitlink').copy()
end, { silent = true, desc = 'Copy git link' })
-- Open git link in browser (normal mode: current line, visual mode: selected range)
vim.keymap.set({ 'n', 'x' }, '<leader>gY', function()
require('gitlink').open()
end, { silent = true, desc = 'Open git link in browser' })- Normal mode: generates a single-line permalink (
#L10) - Visual mode: generates a line range permalink (e.g.
#L10-L20)
| Function | Description |
|---|---|
require('gitlink').copy() |
Copy permalink to clipboard |
require('gitlink').open() |
Open permalink in browser |
| Platform | Single Line | Line Range | Custom Domain Support |
|---|---|---|---|
| GitHub | {url}/blob/{commit}/{path}#L10 |
{url}/blob/{commit}/{path}#L10-L20 |
No |
| GitLab | {url}/-/blob/{commit}/{path}#L10 |
{url}/-/blob/{commit}/{path}#L10-20 |
Yes (matches gitlab. pattern) |
| Bitbucket | {url}/src/{commit}/{path}#lines-10 |
{url}/src/{commit}/{path}#lines-10:20 |
No |
| Gitee | {url}/blob/{commit}/{path}#L10 |
{url}/blob/{commit}/{path}#L10-L20 |
No |
| Codeberg | {url}/src/commit/{commit}/{path}#L10 |
{url}/src/commit/{commit}/{path}#L10-L20 |
No |
| Gitea | {url}/src/commit/{commit}/{path}#L10 |
{url}/src/commit/{commit}/{path}#L10-L20 |
Yes (matches gitea. pattern) |
| Sourcehut | {url}/tree/{commit}/item/{path}#L10 |
{url}/tree/{commit}/item/{path}#L10-L20 |
No |
| GitCode | {url}/blob/{commit}/{path}#L10 |
{url}/blob/{commit}/{path}#L10-L20 |
No |
Like this plugin? Star the repository on GitHub.
Love this plugin? Follow me on GitHub.
If you encounter a bug or have a feature request, please open an issue.
This project is licensed under the GPL-3.0 License.