---------------------------------------------------------------------------- -- lua/gitea/commands.lua -- -- Single :Gitea command with subcommands for issues, PRs, etc. -- Removed "pr open" as requested. Only "list" and "create" remain for PR. ---------------------------------------------------------------------------- local M = {} -------------------------------------------------------------------------- -- A simple completion function for the :Gitea command -------------------------------------------------------------------------- function M._gitea_cmd_complete(arg_lead, cmd_line, cursor_pos) local tokens = vim.split(cmd_line, "%s+") -- If the user hasn't typed anything after ":Gitea", suggest top-level words if #tokens <= 1 then return { "issue", "pr" } end local main_sub = tokens[2] if #tokens == 2 then local candidates = { "issue", "pr" } local results = {} for _, c in ipairs(candidates) do if c:find("^" .. arg_lead) then table.insert(results, c) end end return results end -- If "issue" was selected, next subcommands can be list, create if main_sub == "issue" then if #tokens == 3 then local candidates = { "list", "create" } local results = {} for _, c in ipairs(candidates) do if c:find("^" .. arg_lead) then table.insert(results, c) end end return results end return {} end -- If "pr" was selected, next subcommands can be list, create -- (removed "open" and "merge" as subcommands) if main_sub == "pr" then if #tokens == 3 then local candidates = { "list", "create" } local results = {} for _, c in ipairs(candidates) do if c:find("^" .. arg_lead) then table.insert(results, c) end end return results end return {} end return {} end function M.setup_commands(core) local issues_mod = require("gitea.issues") local telescope_mod = require("gitea.telescope") -- local pulls_mod = require("gitea.pulls") -- if needed vim.api.nvim_create_user_command("Gitea", function(opts) local args = vim.split(opts.args, "%s+") local main = args[1] or "" if main == "issue" then local sub = args[2] or "" if sub == "list" then -- :Gitea issue list telescope_mod.list_issues_in_telescope() elseif sub == "create" then -- :Gitea issue create [owner] [repo]