nvim/init.lua
2023-10-28 00:00:00 +07:00

36 lines
1.1 KiB
Lua

-- Configurations
require('user.config.options')
-- Load plugins with lazy.nvim
require('user.config.lazy')
-- Keymaps and Autocmds can wait
vim.api.nvim_create_autocmd('User', {
pattern = 'VeryLazy',
once = true,
callback = function()
require('user.config.autocmds')
require('user.config.keymap')
end,
group = vim.api.nvim_create_augroup('UserLazyConfig', { clear = true }),
})
-- Open nvim-tree on directory at start up
-- NOTE: the other autocmds are lazy-loaded, so this one can't be there
vim.api.nvim_create_autocmd('VimEnter', {
pattern = '*',
callback = function(args)
if vim.fn.isdirectory(args.file) == 1 then
-- create a new, empty buffer
vim.cmd.enew()
-- wipe the directory buffer
vim.cmd.bw(args.buf)
-- change to the directory
vim.cmd.cd(args.file)
-- open the tree (it will be autoloaded by lazy.nvim here)
require('nvim-tree.api').tree.open()
end
end,
group = vim.api.nvim_create_augroup('NvimTreeStartup', { clear = true }),
})