diff options
Diffstat (limited to 'lua/lvim/core/autocmds.lua')
-rw-r--r-- | lua/lvim/core/autocmds.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index f8da317e..a9f7115a 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -119,6 +119,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) |