Skip to content

cfal/github-line.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

nvim-gh-line

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.

Features

  • 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

Differences from vim-gh-line

  • use_last_edit_hash option: Create links with the commit hash from the last edit of a file
  • open_command option: Takes both a string command, or a Lua function

Installation

Using lazy.nvim:

{
  'cfal/nvim-gh-line',
  config = function()
    require('nvim-gh-line').setup({
      -- Default configuration (optional)
    })
  end
}

Configuration

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,
})

Commands

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

License

MIT

About

A Neovim Lua plugin for GitHub, GitLab, Bitbucket, etc. line links.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages