Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitlink.nvim

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.

Run Tests GitHub License GitHub Issues or Pull Requests GitHub commit activity GitHub Release luarocks

✨ Features

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

📦 Installation

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
    

🔧 Configuration

require('gitlink').setup()

⚙️ Usage

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

🌐 Supported Platforms

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

📣 Self-Promotion

Like this plugin? Star the repository on GitHub.

Love this plugin? Follow me on GitHub.

💬 Feedback

If you encounter a bug or have a feature request, please open an issue.

🙏 Credits

📄 License

This project is licensed under the GPL-3.0 License.

About

Goto/Copy File's Online Link

Topics

Resources

Stars

Watchers

Forks

Releases

Sponsor this project

Used by

Contributors

Languages