Improved flow
This commit is contained in:
136
list-commands.lua
Normal file
136
list-commands.lua
Normal file
@@ -0,0 +1,136 @@
|
||||
-- Script to list all registered commands in Neovim
|
||||
-- Run with: nvim --headless -c "luafile list-commands.lua" -c "qa"
|
||||
|
||||
local commands = vim.api.nvim_get_commands({})
|
||||
|
||||
-- Sort commands alphabetically
|
||||
local sorted_commands = {}
|
||||
for name, cmd in pairs(commands) do
|
||||
table.insert(sorted_commands, {
|
||||
name = name,
|
||||
cmd = cmd
|
||||
})
|
||||
end
|
||||
|
||||
table.sort(sorted_commands, function(a, b)
|
||||
return a.name < b.name
|
||||
end)
|
||||
|
||||
-- Group commands by plugin/source (if we can determine it)
|
||||
local command_groups = {}
|
||||
local conflicts = {}
|
||||
|
||||
-- Check for conflicts (commands with same name but different definitions)
|
||||
local seen_names = {}
|
||||
|
||||
print("=" .. string.rep("=", 78))
|
||||
print("ALL REGISTERED COMMANDS IN NVIM CONFIG")
|
||||
print("=" .. string.rep("=", 78))
|
||||
print()
|
||||
|
||||
for _, item in ipairs(sorted_commands) do
|
||||
local name = item.name
|
||||
local cmd = item.cmd
|
||||
|
||||
-- Check for conflicts
|
||||
if seen_names[name] then
|
||||
if not conflicts[name] then
|
||||
conflicts[name] = {seen_names[name], cmd}
|
||||
else
|
||||
table.insert(conflicts[name], cmd)
|
||||
end
|
||||
else
|
||||
seen_names[name] = cmd
|
||||
end
|
||||
|
||||
-- Format command info
|
||||
local cmd_type = cmd.bang and "!" or ""
|
||||
local cmd_range = cmd.range and "range" or ""
|
||||
local cmd_count = cmd.count ~= "" and cmd.count or ""
|
||||
|
||||
local flags = {}
|
||||
if cmd_type ~= "" then table.insert(flags, "bang") end
|
||||
if cmd_range ~= "" then table.insert(flags, "range") end
|
||||
if cmd_count ~= "" then table.insert(flags, "count=" .. cmd_count) end
|
||||
if cmd.nargs ~= "" then table.insert(flags, "nargs=" .. cmd.nargs) end
|
||||
|
||||
local flags_str = #flags > 0 and (" [" .. table.concat(flags, ", ") .. "]") or ""
|
||||
|
||||
print(string.format("%-30s %s%s", name, cmd.definition or "", flags_str))
|
||||
end
|
||||
|
||||
print()
|
||||
print("=" .. string.rep("=", 78))
|
||||
print("SUMMARY")
|
||||
print("=" .. string.rep("=", 78))
|
||||
print(string.format("Total commands: %d", #sorted_commands))
|
||||
|
||||
if next(conflicts) then
|
||||
print()
|
||||
print("⚠️ CONFLICTS DETECTED:")
|
||||
print("=" .. string.rep("=", 78))
|
||||
for name, defs in pairs(conflicts) do
|
||||
print(string.format("Command '%s' has multiple definitions:", name))
|
||||
for i, def in ipairs(defs) do
|
||||
print(string.format(" %d. %s", i, def.definition or ""))
|
||||
end
|
||||
print()
|
||||
end
|
||||
else
|
||||
print()
|
||||
print("✓ No conflicts detected!")
|
||||
end
|
||||
|
||||
print()
|
||||
print("=" .. string.rep("=", 78))
|
||||
print("COMMANDS BY PLUGIN (from config files)")
|
||||
print("=" .. string.rep("=", 78))
|
||||
print()
|
||||
|
||||
-- Commands from config files
|
||||
local config_commands = {
|
||||
["Tmux Navigator"] = {
|
||||
"TmuxNavigateLeft",
|
||||
"TmuxNavigateDown",
|
||||
"TmuxNavigateUp",
|
||||
"TmuxNavigateRight",
|
||||
"TmuxNavigatePrevious",
|
||||
},
|
||||
["Executor"] = {
|
||||
"ExecutorRun",
|
||||
"ExecutorToggleDetail",
|
||||
"ExecutorSetCommand",
|
||||
},
|
||||
["DBUI"] = {
|
||||
"DBUI",
|
||||
"DBUIToggle",
|
||||
"DBUIAddConnection",
|
||||
"DBUIFindBuffer",
|
||||
"DBUIRenameBuffer",
|
||||
"DBUILastQueryInfo",
|
||||
},
|
||||
["Diffview"] = {
|
||||
"DiffviewOpen",
|
||||
"DiffviewClose",
|
||||
"DiffviewFileHistory",
|
||||
"DiffviewToggleFiles",
|
||||
},
|
||||
["Git Blame"] = {
|
||||
"GitBlameToggle",
|
||||
"GitBlameOpenCommitURL",
|
||||
"GitBlameCopyCommitURL",
|
||||
},
|
||||
["Octo"] = {
|
||||
"Octo",
|
||||
},
|
||||
}
|
||||
|
||||
for plugin, cmds in pairs(config_commands) do
|
||||
print(string.format("%s:", plugin))
|
||||
for _, cmd in ipairs(cmds) do
|
||||
local exists = commands[cmd] ~= nil
|
||||
local status = exists and "✓" or "✗"
|
||||
print(string.format(" %s %s", status, cmd))
|
||||
end
|
||||
print()
|
||||
end
|
||||
Reference in New Issue
Block a user