fixing some issues
This commit is contained in:
@@ -1,40 +1,45 @@
|
||||
-- Load compatibility layer first
|
||||
|
||||
-- =============================================================================
|
||||
-- cargdev/core/init.lua
|
||||
-- Main core initialization for cargdev Neovim config
|
||||
-- =============================================================================
|
||||
|
||||
-- 1. Compatibility Layer
|
||||
require("cargdev.core.compatibility").setup()
|
||||
|
||||
-- 2. Core Options and Keymaps
|
||||
require("cargdev.core.options")
|
||||
require("cargdev.core.keymaps")
|
||||
|
||||
-- Load all Lua files inside `cargdev/core/function/` AFTER plugins are loaded
|
||||
-- 3. Utility: Load all Lua files inside `cargdev/core/function/` AFTER plugins are loaded
|
||||
local function load_functions()
|
||||
local function_path = vim.fn.stdpath("config") .. "/lua/cargdev/core/function"
|
||||
local scan = vim.fn.globpath(function_path, "*.lua", false, true)
|
||||
|
||||
for _, file in ipairs(scan) do
|
||||
local module_name = "cargdev.core.function." .. file:match("([^/]+)%.lua$")
|
||||
local success, err = pcall(require, module_name)
|
||||
|
||||
if not success then
|
||||
vim.notify("Error loading function module: " .. module_name .. "\n" .. err, vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Defer function loading until after plugins are loaded
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyDone",
|
||||
-- 4. Fix: Force filetype detection on BufRead (fix for nvim-tree/plain text issue)
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
-- Load all functions
|
||||
load_functions()
|
||||
vim.cmd("filetype detect")
|
||||
end,
|
||||
once = true,
|
||||
})
|
||||
|
||||
-- Fallback: also try to load on VimEnter if LazyDone doesn't fire
|
||||
-- 5. Load functions immediately
|
||||
load_functions()
|
||||
|
||||
-- 6. Fallback: also try to load on VimEnter if LazyDone doesn't fire
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
-- Wait a bit for plugins to load
|
||||
vim.defer_fn(function()
|
||||
-- Load functions
|
||||
load_functions()
|
||||
end, 200)
|
||||
end,
|
||||
|
||||
Reference in New Issue
Block a user