Improved flow

This commit is contained in:
Morten Olsen
2026-01-26 23:04:14 +01:00
parent d9950b3e4d
commit b3b70bceeb
28 changed files with 4492 additions and 7 deletions

104
check-git-keys.lua Normal file
View File

@@ -0,0 +1,104 @@
-- Check for git-related key conflicts
-- Run with: nvim --headless -c "luafile check-git-keys.lua" -c "qa"
local function get_keymaps()
local keymaps = {}
local modes = { "n", "v", "x", "i", "c", "t", "o" }
for _, mode in ipairs(modes) do
local maps = vim.api.nvim_get_keymap(mode)
for _, map in ipairs(maps) do
if map.lhs and map.lhs:match("g") then
table.insert(keymaps, {
mode = mode,
lhs = map.lhs,
rhs = map.rhs or map.callback or "callback",
desc = map.desc or "",
buffer = map.buffer or 0,
})
end
end
end
return keymaps
end
local keymaps = get_keymaps()
-- Group by key
local by_key = {}
for _, map in ipairs(keymaps) do
local key = map.lhs
if not by_key[key] then
by_key[key] = {}
end
table.insert(by_key[key], map)
end
-- Find conflicts (same key, different actions)
print("=" .. string.rep("=", 70))
print("GIT-RELATED KEYMAPS")
print("=" .. string.rep("=", 70))
print()
local conflicts = {}
for key, maps in pairs(by_key) do
if #maps > 1 then
-- Check if they're actually different
local unique = {}
for _, m in ipairs(maps) do
local rhs_str = type(m.rhs) == "string" and m.rhs or (type(m.rhs) == "function" and "<function>" or tostring(m.rhs))
local sig = m.mode .. ":" .. rhs_str
if not unique[sig] then
unique[sig] = m
end
end
if vim.tbl_count(unique) > 1 then
conflicts[key] = maps
end
end
end
-- Print all git-related keys
local git_keys = {}
for key, maps in pairs(by_key) do
if key:match("leader.*g") or key:match("gh") or key:match("]h") or key:match("%[h") then
for _, map in ipairs(maps) do
table.insert(git_keys, map)
end
end
end
table.sort(git_keys, function(a, b)
if a.lhs ~= b.lhs then
return a.lhs < b.lhs
end
return a.mode < b.mode
end)
print("Git-related keymaps:")
for _, map in ipairs(git_keys) do
local buf_info = map.buffer ~= 0 and (" (buf:" .. map.buffer .. ")") or ""
local rhs_str = type(map.rhs) == "string" and map.rhs or (type(map.rhs) == "function" and "<function>" or tostring(map.rhs))
print(string.format(" %s %-20s -> %-30s %s%s",
map.mode, map.lhs,
rhs_str:sub(1, 30),
map.desc ~= "" and ("(" .. map.desc .. ")") or "",
buf_info))
end
print()
if next(conflicts) then
print("⚠️ POTENTIAL CONFLICTS:")
print("=" .. string.rep("=", 70))
for key, maps in pairs(conflicts) do
print(string.format("Key '%s' has multiple bindings:", key))
for _, map in ipairs(maps) do
local rhs_str = type(map.rhs) == "string" and map.rhs or (type(map.rhs) == "function" and "<function>" or tostring(map.rhs))
print(string.format(" %s: %s (%s)", map.mode, rhs_str, map.desc or "no desc"))
end
print()
end
else
print("✓ No conflicts detected in git-related keys")
end