Giter VIP home page Giter VIP logo

openingh.nvim's Introduction

openingh.nvim

Opens the current file or project page in GitHub.

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

  • 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

Requirements

  • Neovim 0.7.2+

Installation

Example with Packer

wbthomason/packer.nvim

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

Commands

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

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

  • Support the current file cursor position
  • Support visual mode to open a file in range selection
  • Support other version control websites

Contribution

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

License

MIT

openingh.nvim's People

Contributors

almo7aya avatar ansonh avatar bezhermoso avatar bsathvik avatar devidxyz avatar elias-gill avatar enochchau avatar fazibear avatar fearphage avatar juliushaertl avatar lvauthrin avatar msc94 avatar msr1k avatar plaiytiziano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openingh.nvim's Issues

Error when running OpenInGHFile

I get the below error when running OpenInGHFile

There is no active file to open!
Error executing Lua callback: vim/_editor.lua:495: Expected lua string                                       stack traceback:                                                                                                     [C]: in function 'nvim_err_writeln'                                                                          vim/_editor.lua:495: in function 'notify'                                                                    .../site/pack/lazy/opt/openingh.nvim/lua/openingh/utils.lua:6: in function 'notify'                          ...m/site/pack/lazy/opt/openingh.nvim/lua/openingh/init.lua:57: in function 'get_file_url'                   ...vim/site/pack/lazy/opt/openingh.nvim/plugin/openingh.lua:22: in function <...vim/site/pack/lazy/opt/openingh.nvim/plugin/openingh.lua:17>                                                                      Press ENTER or type command to continue

Is it possible to specify a branch to utilize when generating a github link?

Many times I'm navigating through code and generating links to files while I'm on some_branch_x.
I don't necessarily want to link co-workers to my branch specifically when providing reference to a file for discussion, so I usually have to modify the url myself before I pass it along. Is there some way it could be possible to provide a parameter for the branch to use so that I can generate a keymap that will always open the link on develop, or main etc..?

opening files 10 lines below

Hi, just installed your plugin and got weird error. Line selected on GH page is always 10 below cursor position.

Thanks for help!

A bit slow

Love this plugin! But I noticed that opening the page in the browser is a bit slow, is there a way to make it faster?

Support for Windows

This plugin is great. It doesn't seem to work on Windows nvim. It would be great if the support could be extended to Windows users.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.