FeiyouG / commander.nvim

Create and manage keybindings and commands in a more organized manner, and search them quickly through Telescope

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lazy.nvim support to register commands with their plugin spec definition

technicalpickles opened this issue · comments

One benefit I've found with switching to lazy.nvim is that it encourages grouping your config, keybindings, etc together with the plugin. I would love to be able to register commands in the same place.

I've found a way to do this that works, but figured I'd suggest this in case there's a shareable way to do it:

	{
		"gfeiyou/command-center.nvim",
		lazy = true,
		config = function()
			local command_center = require("command_center")

			local plugins = require("lazy").plugins()

			for _, plugin in ipairs(plugins) do
				if plugin.command_center then
					-- only add for enabled plugins
					-- copied from require('lazy.core.plugin').Spec:fix_disabled
					local enabled = not (
							plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled())
						)

					if enabled then
						command_center.add(plugin.command_center)
					end
				end
			end
	},

Great idea, I think it is definitely doable.

It was implemented in 0.2. Thank you for the idea!