Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add cmd for Lazy.nvim #550

Merged
merged 1 commit into from
Dec 19, 2024
Merged

Conversation

gagath
Copy link
Contributor

@gagath gagath commented Dec 19, 2024

Description

Lazy.nvim will by default not load a plugin until ultimately needed. One way to load the plugin is to enter the CodeCompanion* commands.

Add the commands using cmd that will make the plugin load.

Checklist

  • I've read the CONTRIBUTING guidelines and have adhered to them in this PR
  • I've updated the README and ran the make docs command

Lazy.nvim will by default not load a plugin until ultimately needed.
One way to load the plugin is to enter the CodeCompanion* commands.

Add the commands using `cmd` that will make the plugin load.
@olimorris olimorris merged commit f66a7d7 into olimorris:main Dec 19, 2024
@olimorris
Copy link
Owner

olimorris commented Dec 19, 2024

Thanks for the PR.

So even with config = true it doesn't work?

olimorris pushed a commit that referenced this pull request Dec 19, 2024
@gagath
Copy link
Contributor Author

gagath commented Dec 20, 2024

It works with config = true but since the module takes a lot of time to load (31ms on my machine) it is better to lazy load the module only when required to speed up startup. Lazy also supports to lazy load on key bindings. Here is my current configuration with Lazy:

{
	"olimorris/codecompanion.nvim",
	dependencies = {
		"nvim-lua/plenary.nvim",
		"nvim-treesitter/nvim-treesitter",
		{ "MeanderingProgrammer/render-markdown.nvim", ft = { "codecompanion" } },
	},
	keys = {
		{ "<C-a>", "<cmd>CodeCompanionActions<cr>" },
		{ "<C-a>", "<cmd>CodeCompanionActions<cr>", mode = "v" },
		{ "<Leader>a", "<cmd>CodeCompanionChat Toggle<cr>" },
		{ "<Leader>a", "<cmd>CodeCompanionChat Toggle<cr>", mode = "v" },
		{ "ga", "<cmd>CodeCompanionChat Add<cr>", mode = "v" },
	},
	cmd = {
		"CodeCompanion",
		"CodeCompanionChat",
		"CodeCompanionActions",
		"CodeCompanionCmd",
	},
	init = function()
		vim.cmd([[cab cc CodeCompanion]])
	end,
}

On startup the module is not loaded:

image

Once a keybinding or a CodeCompanion* command is run the module is loaded. For example, after opening a chat window:

image

The point of Lazy is to load plugins only when required to speed up nvim startup. Please reconsider the revert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants