summaryrefslogtreecommitdiff
path: root/lua/lvim/core/autocmds.lua
diff options
context:
space:
mode:
authorLostNeophyte <[email protected]>2023-01-18 14:21:31 +0100
committeropalmay <[email protected]>2023-01-20 23:52:10 +0200
commit74bd5e16aa2a9dc4bd751618982fcd6cfba3a036 (patch)
treeac67ecf269cbfb93a008a6279b93a212a334b618 /lua/lvim/core/autocmds.lua
parent2d3140f0d7497cc8352190b2fd4737a7a3420a68 (diff)
perf: lazy load most plugins
Diffstat (limited to 'lua/lvim/core/autocmds.lua')
-rw-r--r--lua/lvim/core/autocmds.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua
index 499f830e..bb080ced 100644
--- a/lua/lvim/core/autocmds.lua
+++ b/lua/lvim/core/autocmds.lua
@@ -121,6 +121,35 @@ function M.load_defaults()
end,
},
},
+ { -- taken from AstroNvim
+ "BufEnter",
+ {
+ group = "_dir_opened",
+ once = true,
+ callback = function(args)
+ local bufname = vim.api.nvim_buf_get_name(args.buf)
+ if require("lvim.utils").is_directory(bufname) then
+ vim.api.nvim_del_augroup_by_name "_dir_opened"
+ vim.cmd "do User DirOpened"
+ vim.api.nvim_exec_autocmds("BufEnter", {})
+ end
+ end,
+ },
+ },
+ { -- taken from AstroNvim
+ { "BufRead", "BufWinEnter", "BufNewFile" },
+ {
+ group = "_file_opened",
+ once = true,
+ callback = function(args)
+ local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf })
+ if not (vim.fn.expand "%" == "" or buftype == "nofile") then
+ vim.cmd "do User FileOpened"
+ require("lvim.lsp").setup()
+ end
+ end,
+ },
+ },
}
M.define_autocmds(definitions)