♻️ refactor(full-scope)!: major revision refactoring
Code layout has been changed and improoved. Annotations are added for documentation. Automated through utility functions and data tables BREAKING CHANGE: Tested from clean. Now properly uses LuaRocks to install dependencies.
This commit is contained in:
+32
-20
@@ -1,25 +1,37 @@
|
||||
---@module "data"
|
||||
--- This module aggregates various utility modules used throughout the configuration.
|
||||
--- It provides a centralized way to access keymaps, data types, utility functions, commands, and dashboard utilities.
|
||||
--- This module aggregates various data tables used throughout the configuration.
|
||||
local M = {}
|
||||
|
||||
local keys = require("data.keys")
|
||||
local types = require("data.types")
|
||||
local func = require("data.func")
|
||||
local cmd = require("data.cmd")
|
||||
local deps = require("data.deps")
|
||||
local dash = require("data.dash")
|
||||
-- Explicitly specify for LSP support
|
||||
M.keys = require("data.keys")
|
||||
M.types = require("data.types")
|
||||
M.func = require("data.func")
|
||||
M.cmd = require("data.cmd")
|
||||
M.deps = require("data.deps")
|
||||
M.dash = require("data.dash")
|
||||
|
||||
---@alias DataModule
|
||||
---| { keys: table, types: table, func: table, cmd: table, deps: table, dash: table }
|
||||
-- Function to iterate over files in the directory
|
||||
local function read_data_dir()
|
||||
-- Getting the root path for the current module directory
|
||||
local dir_path = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h")
|
||||
|
||||
---@type DataModule
|
||||
local data = {
|
||||
keys = keys,
|
||||
types = types,
|
||||
func = func,
|
||||
cmd = cmd,
|
||||
deps = deps,
|
||||
dash = dash,
|
||||
}
|
||||
-- Open the directory
|
||||
local files = vim.fn.readdir(dir_path)
|
||||
|
||||
return data
|
||||
for _, file in ipairs(files) do
|
||||
-- Skip init.lua
|
||||
if file ~= "init.lua" and file:match(".*%.lua$") then
|
||||
-- Get the module name without the .lua extension
|
||||
local module_name = file:sub(1, -5)
|
||||
-- Load the module if not already explicitly set
|
||||
if not M[module_name] then
|
||||
M[module_name] = require("data." .. module_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Read the directory and load any additional modules
|
||||
read_data_dir()
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user