fix: change global config to default option

This commit is contained in:
JuanZoran
2023-03-12 20:09:08 +08:00
parent 493fad6a3f
commit bc8c673ee0
10 changed files with 287 additions and 184 deletions

View File

@@ -1,8 +1,9 @@
local Trans = require('Trans')
local M = Trans.metatable('backend')
local conf = Trans.conf
--- INFO :Parse online engine keys config file
local path = Trans.conf.dir .. '/Trans.json'
local path = conf.dir .. '/Trans.json'
local file = io.open(path, "r")
if file then
@@ -14,19 +15,12 @@ if file then
end
local default_opts = vim.deepcopy(Trans.conf.backend)
for name, private_opts in pairs(result or {}) do
local opts = vim.tbl_extend('keep', Trans.conf.backend[name] or {}, default_opts, private_opts)
local backend = M[name]
local opts = vim.tbl_extend('keep', conf.backend[name] or {}, conf.backend.default, private_opts)
for k, v in pairs(opts) do
if not backend[k] then
backend[k] = v
end
M[name][k] = v
end
end
end
return M