A Neovim Lua plugin for GitHub, GitLab, Bitbucket, etc. line links.
This is a Lua rewrite of the original vim-gh-line plugin by ruanyl.
- Open the current line in GitHub/GitLab/Bitbucket/SourceHut/Cgit
- Open the current line blame in GitHub/GitLab/Bitbucket/SourceHut/Cgit
- Open the repository home page
use_last_edit_hashoption: Create links with the commit hash from the last edit of a fileopen_commandoption: Takes both a string command, or a Lua function
Using lazy.nvim:
{
'cfal/nvim-gh-line',
config = function()
require('nvim-gh-line').setup({
-- Default configuration (optional)
})
end
}require('nvim-gh-line').setup({
-- Default keymap for repo home page, nil to disable
repo_map = '<leader>go',
-- Default keymap for current line, nil to disable
line_map = '<leader>gh',
-- Should the plugin use default mappings if not specified
line_map_default = true,
-- Default keymap for blame, nil to disable
line_blame_map = '<leader>gb',
-- Should the plugin use default blame mapping if not specified
line_blame_map_default = true,
-- Enable debug traces
trace = false,
-- Command or function to open URLs
-- nil for auto-detect based on OS
open_command = nil,
-- Use canonical references (full commit hashes)
use_canonical = true,
-- Use commit hash from the last edit of the target file
use_last_edit_hash = false,
-- For GitLab URLs, force http instead of https
gitlab_only_http = false,
-- For cgit repos, patterns to transform git URLs to cgit web URLs
cgit_url_pattern_sub = {},
-- Default remote name, auto-detect if empty
git_remote = "",
-- Always ask for remote interactively
always_interactive = false,
-- Custom domain for GitHub Enterprise
github_domain = nil,
-- Custom domain for GitLab self-hosted
gitlab_domain = nil,
-- Custom domain for SourceHut self-hosted
srht_domain = nil,
}):GH- Open the current line in the browser:GB- Open the current line blame in the browser:GHInteractive- Open the current line in the browser, but always prompt for remote:GBInteractive- Open the current line blame in the browser, but always prompt for remote
All commands accept ranges, e.g., :2,10GH will open lines 2-10 in the browser.
MIT