diff --git a/git.lua b/git.lua index a14fc67..abd5457 100644 --- a/git.lua +++ b/git.lua @@ -2771,10 +2771,28 @@ local function init(argmatcher, full_init) -- function, the sort order when displaying completions is defined by the -- alias function. But these do affect input line parsing and coloring. local aliases = get_git_aliases() + local complex, chain for _, a in ipairs(aliases) do - local linked = linked_parsers[a.command] + local linked + if not clink_version.supports_onalias then + linked = linked_parsers[a.command] + end if linked then table.insert(commands, a.name..linked) + else + local bang = a.command:match("^%!") and true or nil + local command = a.command:sub(bang and 2 or 1) + complex = complex or {} + chain = chain or {} + complex[a.name] = command + chain[a.name] = bang + table.insert(commands, a.name) + end + end + + if complex then + commands.onalias = function(arg_index, word, word_index, line_state, user_data) -- luacheck: no unused + return complex[word], chain[word] end end diff --git a/modules/arghelper.lua b/modules/arghelper.lua index 66ca102..239cf71 100644 --- a/modules/arghelper.lua +++ b/modules/arghelper.lua @@ -100,6 +100,12 @@ -------------------------------------------------------------------------------- -- Changes: -- +-- 2024/07/23 +-- - Support for `onalias=func`. +-- +-- 2024/04/11 +-- - Support for `hide_unless=func`. +-- -- 2023/11/18 -- - Support for `hide=true` in _addexarg(). -- @@ -394,6 +400,7 @@ if not tmp._addexflags or not tmp._addexarg then list.loopchars = tbl.loopchars list.nosort = tbl.nosort list.onadvance = tbl.onadvance + list.onalias = tbl.onalias list.onlink = tbl.onlink list.onarg = tbl.onarg if hide_unless then diff --git a/modules/clink_version.lua b/modules/clink_version.lua index 5ab9951..b166d36 100644 --- a/modules/clink_version.lua +++ b/modules/clink_version.lua @@ -22,5 +22,6 @@ exports.has_volatile_matches_fix = (clink_version_encoded >= 10040013) exports.supports_argmatcher_onlink = (clink_version_encoded >= 10050014) exports.has_linked_setdelayinit_fix = (clink_version_encoded >= 10050016) exports.supports_argmatcher_nowordbreakchars = (clink_version_encoded >= 10050017) +exports.supports_onalias = (clink_version_encoded >= 10060018) return exports