close
Skip to content

wsdjeg/gitlink.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitlink.nvim

A Lua plugin for Neovim to generate and open permalink of current file in browser or copy the link to clipboard.

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
  • 🌐 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.

About

Goto/Copy File's Online Link

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Contributors