From 318b56c1c425d90c71c0b63c6ec7655a8f019fa1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Jan 2023 13:00:16 +0100 Subject: [PATCH] fix(autocmds): load autocmds during startup when argc > 0. Fixes #34 --- lua/lazyvim/config/init.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 46bf17d7..26ee2f96 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -78,15 +78,21 @@ function M.setup(opts) ) end - -- autocmds and keymaps can wait to load - vim.api.nvim_create_autocmd("User", { - group = vim.api.nvim_create_augroup("LazyVim", { clear = true }), - pattern = "VeryLazy", - callback = function() - M.load("autocmds") - M.load("keymaps") - end, - }) + if vim.fn.argc() == 0 then + -- autocmds and keymaps can wait to load + vim.api.nvim_create_autocmd("User", { + group = vim.api.nvim_create_augroup("LazyVim", { clear = true }), + pattern = "VeryLazy", + callback = function() + M.load("autocmds") + M.load("keymaps") + end, + }) + else + -- load them now so they affect the opened buffers + M.load("autocmds") + M.load("keymaps") + end require("lazy.core.util").try(function() if type(M.colorscheme) == "function" then