1
0
Fork 1
Dotfiles_nvim/lua/util/config.lua

30 lines
710 B
Lua
Raw Normal View History

2024-09-07 23:50:39 +00:00
local C = require('util.const')
local F = require('util.finder')
local CONFIG = {}
CONFIG.config_dir = F.project_dir .. "/" .. C.CONFIG_DIR
function CONFIG.get(module, name)
local config_file_path = CONFIG.config_dir .. module .. ".json"
if vim.fn.filereadable(config_file_path) == 0 then
return nil
end
local config_file = vim.fn.readfile(config_file_path, "")
local succes, data = pcall(function()
return vim.json.decode(table.concat(config_file, ""))
end)
if not succes or data then
return nil
end
return table.concat(
vim.split(data[name], C.PROJECT_DIR_PLACEHOLDER, { plain = true}),
F.project_dir
)
end
return CONFIG