Opens the current file or project page in GitHub.
-
Features
- Supports macOS, Linux, Windows and WSL
- Works with detached HEAD and supports checked out branches or forks
- Automatically selects the correct line number on the file page
- Supports GitHub, GitHub Enterprise, GitLab, and Bitbucket
-
Demo
- Neovim 0.7.2+
-- init.lua
require("packer").startup(function()
use "almo7aya/openingh.nvim"
end)
-
:OpenInGHRepo
- Opens the project's git repository page in GitHub.
-
:OpenInGHFile
- Opens the current file page in GitHub. This command supports ranges.
-
:OpenInGHFileLines
- Opens the current file page in GitHub. This command supports ranges.
All of the commands above optionally take a register, e.g. :OpenInGHFileLines+
.
In this case, the URL will not be opened in the browser, but put into the register given.
This is especially useful if you're running neovim on a remote machine, but want to open the URL locally.
You can call the commands directly or define mappings them:
-- for repository page
vim.api.nvim_set_keymap("n", "<Leader>gr", ":OpenInGHRepo <CR>", { silent = true, noremap = true })
-- for current file page
vim.api.nvim_set_keymap("n", "<Leader>gf", ":OpenInGHFile <CR>", { silent = true, noremap = true })
vim.api.nvim_set_keymap("v", "<Leader>gf", ":OpenInGHFileLines <CR>", { silent = true, noremap = true })
- Support the current file cursor position
- Support visual mode to open a file in range selection
- Support other version control websites
Feel free to open an issue or a pull request if you have any suggestions or improvements