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

Major performance improvements, made lazy loading false by default #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Selyss
Copy link

@Selyss Selyss commented Jan 5, 2024

By using the lazy package manager's built in features, I have improved the start-up time from ~200ms to ~17ms (on my machine). This was achieved by loading plugins either lazily or by tweaking the plugin load order. The changes are commented and explained in the code, but just to explain briefly:

The cmd option only loads a plugin when a certain command is entered, not on start-up.

The event option only loads plugins when certain events in neovim's event loop are triggered.

The keys option allows you to set keymaps that actually load the plugin itself. For example, telescope is not loaded until the user executes a telescope key command. The end user doesn't notice this, and not loading a major plugin largely improves performance.

The only other change made was to make lazy loading off by default. In the config, I noticed a lot of lazy = false. Lazy has an option to specify the default state of lazy loading, which I have switched off by default in the init.lua. No longer do you need to specify when lazy loading should be false, only when it's true.

I have documented all options with comments, in hopes that anyone with the config can easily understand or have a point of reference if they are wondering what the line of code does. If anyone has any questions about these changes, feel free to let me know.👍

@KisNJ
Copy link

KisNJ commented Feb 13, 2024

When i have mason cmd="Mason" set Spawning language server with cmd: table: 0x7077f887dc90 failed. The language server is either not installed, missing from PATH, or not executable. removing cmd resolves the issue

@Selyss
Copy link
Author

Selyss commented Feb 13, 2024

@KisNJ I don't believe that would cause the issue. The issue may be caused by another plugin that depends on mason being lazy loaded.

That specific lazy load option for mason is used in folke's neovim configuration LazyVim and many other configurations. Please link your configuration so I can look into that more. If you're able to reproduce the error without any other plugins that would affect the startup, let me know.

@GNOMES
Copy link

GNOMES commented Mar 7, 2024

Tried making your suggested changes to Telescope, and found that the keys mapped your way did not always load Telescope reliably for all Telescope builtins I had mapped.

I found this more reliable:

keys = {
		{
			"<leader>gc",
			function()
				require("telescope.builtin").git_commits()
			end,
			desc = "Telescope [g]it_[c]ommits",
		},
		{
			"<leader>ff",
			function()
				require("telescope.builtin").find_files()
			end,
			desc = "Telescope [f]ind_[f]iles",
		},
},

@Selyss
Copy link
Author

Selyss commented Mar 8, 2024

Tried making your suggested changes to Telescope, and found that the keys mapped your way did not always load Telescope reliably for all Telescope builtins I had mapped.

I found this more reliable:

keys = {
		{
			"<leader>gc",
			function()
				require("telescope.builtin").git_commits()
			end,
			desc = "Telescope [g]it_[c]ommits",
		},
		{
			"<leader>ff",
			function()
				require("telescope.builtin").find_files()
			end,
			desc = "Telescope [f]ind_[f]iles",
		},
},

Oh that's my bad, I may change that in my pr. Are there any specific cases where it was unreliable?

@GNOMES
Copy link

GNOMES commented Mar 16, 2024

I take my statement back, it seems I may have had conflicting bindings. Your formatting works for me on fresh config.

Not sure if there are benefits to either your method or mine.

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.

3 participants