├── .gitignore ├── README.md ├── Makefile ├── tests ├── github-pr │ └── github_pr_spec.lua └── minimal_init.lua ├── plugin └── github_pr.lua ├── LICENSE ├── lua └── github-pr │ └── pull_request.lua └── doc └── my-template-docs.txt /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/plenary.nvim 2 | .luarc.json 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Github Pull Request Neovim Extension 2 | 3 | A small Neovim wrapper around the GitHub CLI `gh pr create` command to make creating pull requests in Neovim nicer. 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TESTS_INIT=tests/minimal_init.lua 2 | TESTS_DIR=tests/ 3 | 4 | .PHONY: test 5 | 6 | test: 7 | @nvim \ 8 | --headless \ 9 | --noplugin \ 10 | -u ${TESTS_INIT} \ 11 | -c "PlenaryBustedDirectory ${TESTS_DIR} { minimal_init = '${TESTS_INIT}' }" 12 | -------------------------------------------------------------------------------- /tests/github-pr/github_pr_spec.lua: -------------------------------------------------------------------------------- 1 | local gh = require("github-pr.pull_request") 2 | 3 | describe("setup", function() 4 | it("should work with default values", function() 5 | assert(gh.pull_request(), " successfully") 6 | end) 7 | 8 | it("should work with custom values", function() 9 | gh.setup({ opt = "custom" }) 10 | assert(gh.pull_request() == "custom", "does not provide custom value") 11 | end) 12 | end) 13 | -------------------------------------------------------------------------------- /tests/minimal_init.lua: -------------------------------------------------------------------------------- 1 | local plenary_dir = os.getenv("PLENARY_DIR") or "/tmp/plenary.nvim" 2 | local is_not_a_directory = vim.fn.isdirectory(plenary_dir) == 0 3 | if is_not_a_directory then 4 | vim.fn.system({ "git", "clone", "https://github.com/nvim-lua/plenary.nvim", plenary_dir }) 5 | end 6 | 7 | vim.opt.rtp:append(".") 8 | vim.opt.rtp:append(plenary_dir) 9 | 10 | vim.cmd("runtime plugin/plenary.vim") 11 | require("plenary.busted") 12 | -------------------------------------------------------------------------------- /plugin/github_pr.lua: -------------------------------------------------------------------------------- 1 | if vim.fn.has("nvim-0.7.0") == 0 then 2 | vim.api.nvim_err_writeln("github-pr requires at least nvim-0.7.0.1") 3 | return 4 | end 5 | 6 | -- make sure this file is loaded only once 7 | if vim.g.loaded_github_pr == 1 then 8 | return 9 | end 10 | vim.g.loaded_github_pr = 1 11 | 12 | -- create any global command that does not depend on user setup 13 | -- usually it is better to define most commands/mappings in the setup function 14 | -- Be careful to not overuse this file! 15 | local gh = require("github-pr.pull_request") 16 | vim.api.nvim_create_user_command("GithubPr", gh.pull_request, {}) 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Ellison 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lua/github-pr/pull_request.lua: -------------------------------------------------------------------------------- 1 | local popup = require "plenary.popup" 2 | local Job = require('plenary.job') 3 | 4 | 5 | ---@class Config 6 | ---@field opt string Your config option 7 | local config = { 8 | opt = "Hello!", 9 | } 10 | 11 | ---@class BrowseModule 12 | local M = {} 13 | 14 | ---@type Config 15 | M.config = config 16 | 17 | ---@param args Config? 18 | M.setup = function(args) 19 | M.config = vim.tbl_deep_extend("force", M.config, args or {}) 20 | end 21 | 22 | 23 | local function create_border_popup(borderchars) 24 | local _, config = popup.create("popup with custom border", { 25 | line = 8, 26 | col = 55, 27 | padding = { 0, 3, 0, 3 }, 28 | borderchars = borderchars, 29 | }) 30 | local border_id = config.border.win_id 31 | local border_bufnr = vim.api.nvim_win_get_buf(border_id) 32 | print(border_id) 33 | print(border_bufnr) 34 | end 35 | 36 | ---@return string 37 | M.pull_request = function() 38 | 39 | -- local opts = { 40 | -- \ "on_stdout": function("s:RgEvent"), 41 | -- \ "on_stderr": function("s:RgEvent"), 42 | -- \ "on_exit": function("s:RgEvent"), 43 | -- \ "pattern": a:pattern 44 | -- \ } 45 | -- let s:rg_job = jobstart(a:cmd, opts) 46 | local output = "" 47 | vim.fn.jobstart("gh pr create", { 48 | on_stdout = function(_, d, _) 49 | output = output .. vim.fn.join(d) 50 | print(output) 51 | end, 52 | }) 53 | 54 | return M.config.opt 55 | end 56 | 57 | return M 58 | -------------------------------------------------------------------------------- /doc/my-template-docs.txt: -------------------------------------------------------------------------------- 1 | *my-template-docs.txt* For Neovim >= 0.8.0 Last change: 2023 August 17 2 | 3 | ============================================================================== 4 | Table of Contents *my-template-docs-table-of-contents* 5 | 6 | 1. A Neovim Plugin Template |my-template-docs-a-neovim-plugin-template| 7 | - Using it |my-template-docs-a-neovim-plugin-template-using-it| 8 | - Features and structure|my-template-docs-a-neovim-plugin-template-features-and-structure| 9 | 10 | ============================================================================== 11 | 1. A Neovim Plugin Template *my-template-docs-a-neovim-plugin-template* 12 | 13 | 14 | 15 | A template repository for Neovim plugins. 16 | 17 | 18 | USING IT *my-template-docs-a-neovim-plugin-template-using-it* 19 | 20 | Via `gh` 21 | 22 | > 23 | $ gh repo create my-plugin -p ellisonleao/nvim-plugin-template 24 | < 25 | 26 | Viagithub web page: 27 | 28 | Click on `Use this template` 29 | 30 | 31 | 32 | 33 | FEATURES AND STRUCTURE*my-template-docs-a-neovim-plugin-template-features-and-structure* 34 | 35 | - 100% Lua 36 | - Github actions for: 37 | - running tests using plenary.nvim and busted 38 | - check for formatting errors (Stylua) 39 | - vimdocs autogeneration from README.md file 40 | - luarocks release (LUAROCKS_API_KEY secret configuration required) 41 | 42 | 43 | PLUGIN STRUCTURE ~ 44 | 45 | > 46 | . 47 | lua 48 |    plugin_name 49 |       module.lua 50 |    plugin_name.lua 51 | Makefile 52 | plugin 53 |    plugin_name.lua 54 | README.md 55 | tests 56 |    minimal_init.lua 57 |    plugin_name 58 |    plugin_name_spec.lua 59 | < 60 | 61 | ============================================================================== 62 | 2. Links *my-template-docs-links* 63 | 64 | 1. *GitHub Workflow Status*: https://img.shields.io/github/actions/workflow/status/ellisonleao/nvim-plugin-template/lint-test.yml?branch=main&style=for-the-badge 65 | 2. *Lua*: https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua 66 | 3. **: https://docs.github.com/assets/cb-36544/images/help/repository/use-this-template-button.png 67 | 68 | Generated by panvimdoc 69 | 70 | vim:tw=78:ts=8:noet:ft=help:norl: 71 | --------------------------------------------------------------------------------