2022-09-25 23:30:27 +03:00
|
|
|
if vim.g.openingh then
|
2022-09-26 22:57:58 +03:00
|
|
|
return
|
2022-09-25 23:30:27 +03:00
|
|
|
end
|
|
|
|
|
vim.g.openingh = true
|
|
|
|
|
|
2022-10-16 00:28:16 -04:00
|
|
|
local openingh = require("openingh")
|
2022-09-26 23:53:18 +03:00
|
|
|
|
2023-06-17 20:40:36 +09:00
|
|
|
local complete_list = { 'branch-priority', 'commit-priority', }
|
|
|
|
|
local complete_func = function(arg_lead, _, _)
|
|
|
|
|
return vim.tbl_filter(function(item)
|
|
|
|
|
return vim.startswith(item, arg_lead)
|
|
|
|
|
end, complete_list)
|
|
|
|
|
end
|
|
|
|
|
|
2023-03-21 09:39:12 -04:00
|
|
|
vim.api.nvim_create_user_command("OpenInGHFile", function(opts)
|
2023-04-08 20:25:43 +02:00
|
|
|
if opts.range == 0 then -- Nothing was selected
|
2023-06-17 20:40:36 +09:00
|
|
|
openingh.open_file(opts.args)
|
2023-04-08 20:25:43 +02:00
|
|
|
else -- Current line or block was selected
|
2023-06-17 20:40:36 +09:00
|
|
|
openingh.open_file(opts.args, opts.line1, opts.line2)
|
2023-03-21 09:39:12 -04:00
|
|
|
end
|
|
|
|
|
end, {
|
|
|
|
|
range = true,
|
2023-06-17 20:40:36 +09:00
|
|
|
nargs = '?',
|
|
|
|
|
complete = complete_func,
|
2023-03-21 09:39:12 -04:00
|
|
|
})
|
2022-09-25 23:30:27 +03:00
|
|
|
|
2023-05-26 22:31:02 +03:00
|
|
|
vim.api.nvim_create_user_command("OpenInGHFileLines", function(opts)
|
|
|
|
|
if opts.range == 0 then -- Nothing was selected
|
2023-06-17 20:40:36 +09:00
|
|
|
openingh.open_file(opts.args, opts.line1)
|
2023-05-26 22:31:02 +03:00
|
|
|
else -- Current line or block was selected
|
2023-06-17 20:40:36 +09:00
|
|
|
openingh.open_file(opts.args, opts.line1, opts.line2)
|
2023-05-26 22:31:02 +03:00
|
|
|
end
|
|
|
|
|
end, {
|
|
|
|
|
range = true,
|
2023-06-17 20:40:36 +09:00
|
|
|
nargs = '?',
|
|
|
|
|
complete = complete_func,
|
2023-05-26 22:31:02 +03:00
|
|
|
})
|
|
|
|
|
|
2022-09-25 23:30:27 +03:00
|
|
|
vim.api.nvim_create_user_command("OpenInGHRepo", function()
|
2023-06-17 20:40:36 +09:00
|
|
|
openingh.open_repo(opts.args)
|
|
|
|
|
end, {
|
|
|
|
|
nargs = '?',
|
|
|
|
|
complete = complete_func,
|
|
|
|
|
})
|