Skip to content

Commit

Permalink
rename to adopure
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem Jan Noort committed Jun 22, 2024
1 parent 71ded37 commit 5eb04bc
Show file tree
Hide file tree
Showing 24 changed files with 335 additions and 335 deletions.
2 changes: 1 addition & 1 deletion adopure.nvim-0.0.1-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ rockspec_format = "3.0"
package = "adopure.nvim"
version = "0.0.1-1"
source = {
url = "git+https://github.com/Willem-J-an/ado.nvim",
url = "git+https://github.com/Willem-J-an/adopure.nvim",
}
dependencies = {
"plenary.nvim",
Expand Down
135 changes: 0 additions & 135 deletions lua/ado/types.lua

This file was deleted.

28 changes: 14 additions & 14 deletions lua/ado.lua → lua/adopure.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local M = {}

---@type StateManager|nil
---@type adopure.StateManager|nil
local state_manager
---@return AdoState
---@return adopure.AdoState
function M.get_loaded_state()
assert(state_manager and state_manager.state, "Choose and activate a pull request first;")
return state_manager.state
Expand Down Expand Up @@ -37,22 +37,22 @@ local function execute_or_prompt(sub_impl, subcommand_args, subcommand)
sub_impl[subcommand_args[1]](ok and opts or {})
end

---@class SubCommand
---@class adopure.SubCommand
---@field impl fun(args:string[])
---@field complete_args? string[]

---Initial load of state_manager with all open PRs;
---@return StateManager
---@return adopure.StateManager
function M.load_state_manager()
if not state_manager then
local context = require("ado.state").AdoContext:new()
state_manager = require("ado.state").StateManager:new(context)
local context = require("adopure.state").AdoContext:new()
state_manager = require("adopure.state").StateManager:new(context)
end
assert(state_manager, "StateManager should not be nil after loading;")
return state_manager
end

---@type table<string, SubCommand>
---@type table<string, adopure.SubCommand>
local subcommand_tbl = {
load = {
complete_args = { "context", "threads" },
Expand All @@ -74,13 +74,13 @@ local subcommand_tbl = {
impl = function(args)
local sub_impl = {
comment = function(opts)
require("ado.thread").submit_comment(M.get_loaded_state(), opts)
require("adopure.thread").submit_comment(M.get_loaded_state(), opts)
end,
vote = function(opts)
require("ado.review").submit_vote(M.get_loaded_state(), opts)
require("adopure.review").submit_vote(M.get_loaded_state(), opts)
end,
thread_status = function(opts)
require("ado.thread").update_thread_status(M.get_loaded_state(), opts)
require("adopure.thread").update_thread_status(M.get_loaded_state(), opts)
end,
}
execute_or_prompt(sub_impl, args, "submit")
Expand All @@ -91,16 +91,16 @@ local subcommand_tbl = {
impl = function(args)
local sub_impl = {
quickfix = function(opts)
require("ado.quickfix").render_quickfix(M.get_loaded_state().pull_request_threads, opts)
require("adopure.quickfix").render_quickfix(M.get_loaded_state().pull_request_threads, opts)
end,
thread_picker = function(opts)
require("ado.pickers.thread").choose_thread(M.get_loaded_state(), opts)
require("adopure.pickers.thread").choose_thread(M.get_loaded_state(), opts)
end,
new_thread = function(opts)
require("ado.thread").new_thread_window(M.get_loaded_state(), opts)
require("adopure.thread").new_thread_window(M.get_loaded_state(), opts)
end,
existing_thread = function(opts)
require("ado.thread").open_thread_window(M.get_loaded_state(), opts)
require("adopure.thread").open_thread_window(M.get_loaded_state(), opts)
end,
}
execute_or_prompt(sub_impl, args, "open")
Expand Down
12 changes: 6 additions & 6 deletions lua/ado/activate.lua → lua/adopure/activate.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local M = {}

---@param pull_request PullRequest
---@param pull_request adopure.PullRequest
local function confirm_open_in_diffview(pull_request)
vim.ui.input({ prompt = "Open in diffview? <CR> / <ESC>" }, function(input)
if not input then
Expand All @@ -12,21 +12,21 @@ local function confirm_open_in_diffview(pull_request)
end

local function buffer_marker_autocmd(state)
local augroup = vim.api.nvim_create_augroup("ado.nvim", { clear = true })
local augroup = vim.api.nvim_create_augroup("adopure.nvim", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter" }, {
group = augroup,
callback = function()
if state.pull_request_threads then
require("ado.marker").create_buffer_extmarks(state.pull_request_threads)
require("adopure.marker").create_buffer_extmarks(state.pull_request_threads)
end
end,
})
end

---@param state AdoState
---@param state adopure.AdoState
function M.activate_pull_request_context(state)
require("ado.marker").create_buffer_extmarks(state.pull_request_threads)
require("ado.git").confirm_checkout_and_open(state.active_pull_request, function()
require("adopure.marker").create_buffer_extmarks(state.pull_request_threads)
require("adopure.git").confirm_checkout_and_open(state.active_pull_request, function()
confirm_open_in_diffview(state.active_pull_request)
end)
buffer_marker_autocmd(state)
Expand Down
Loading

0 comments on commit 5eb04bc

Please sign in to comment.