Home

Awesome

openingh.nvim

Opens the current file or project page in GitHub.

Lua GitHub release (latest by date) lint with luacheck GitHub Workflow Status

Requirements

Installation

Example with Packer

wbthomason/packer.nvim

-- init.lua
require("packer").startup(function()
  use "almo7aya/openingh.nvim"
end)

Commands

Registers

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.

Priority

At first, this plugin try to identify the page url based on the current branch you are working in, and if it fails then switches its base to commit.

This behavior can be inverted via bang !, e.g. :OpenInGHFile!.

Since commit based url tends to have long durablity compared to branch based one, it can be useful in some situation. It won't be affected by subsequent commits, branch deletion after merge, and so on.

Usage

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

TODO

Contribution

Feel free to open an issue or a pull request if you have any suggestions or improvements

License

MIT