30 lines
710 B
Lua
30 lines
710 B
Lua
|
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
|