Skip to content

Commit

Permalink
📝 Update README and add commit()
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed Jun 2, 2023
1 parent 9d5e870 commit c6050ed
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ GithubUtils.nvim

- [Neovim](https://github.com/neovim/neovim) (tested with 0.9.0)
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
- [git](https://git-scm.com/)
- [Github CLI](https://cli.github.com/)

## Installation
Expand All @@ -20,6 +21,49 @@ require('lazy').setup({
})
```

## Public methods

### `require('githubutils').open()`

Opens up the Github Web-IDE with the current line pre-selected.

Can be used from visual mode when passing `{ v = true}`
(`require('githubutils').open({ v = true })`) which will then pre-select
the visually selected lines.


### `require('githubutils').repo()`

Opens up the [base Github page](https://github.com/mistweaverco/githubutils.nvim)
of the current git repository you're in.

### `require('githubutils').commit()`

Prompts you for a commit hash and opens up the Github web-view of
[this commit](https://github.com/mistweaverco/githubutils.nvim).

If you leave the prompt empty and press enter,
The Github web-view of all commit for the current branch will be opened.

### `require('githubutils').pulls()`

Lists all open pull-requests.
Takes you to the web-view of the pull-request selected.

### `require('githubutils').issues()`

Lists all open issues.
Takes you to the web-view of the issue selected.

### `require('githubutils').actions()`

Takes you to the web-view of the actions.

### `require('githubutils').labels()`

Lists all labels.
Takes you to the web-view of the label selected.

## Configuration

With [which-key.nvim](https://github.com/folke/which-key.nvim):
Expand All @@ -33,6 +77,7 @@ wk.register({
name = "Github Utils",
o = { "<Cmd>lua require('githubutils').open()<CR>", "Open" },
O = { "<Cmd>lua require('githubutils').repo()<CR>", "Repo" },
c = { "<Cmd>lua require('githubutils').commit()<CR>", "Commit" },
p = { "<Cmd>lua require('githubutils').pulls()<CR>", "Pulls" },
i = { "<Cmd>lua require('githubutils').issues()<CR>", "Issues" },
a = { "<Cmd>lua require('githubutils').actions()<CR>", "Actions" },
Expand Down
14 changes: 14 additions & 0 deletions lua/githubutils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ function open_from_normal_mode()
show_remote_names_picker_and_open_slug("blob/" .. branch .. "/" .. filename .. "?plain=1#L" .. line_number)
end

function prompt_user_for_commit_hash_and_open_github()
local commit_hash = vim.fn.input("Commit hash: ")
if (commit_hash == nil or commit_hash == "") then
local branch = Helper.get_current_git_branch()
show_remote_names_picker_and_open_slug("commits/" .. branch)
else
show_remote_names_picker_and_open_slug("commit/" .. commit_hash)
end
end

local M = {}

function M.setup()
Expand Down Expand Up @@ -105,5 +115,9 @@ function M.actions()
show_remote_names_picker_and_open_slug("actions")
end

function M.commit()
prompt_user_for_commit_hash_and_open_github()
end

return M

0 comments on commit c6050ed

Please sign in to comment.