Open peter-bread opened 3 months ago
local t1 = {
servers = {
lua_ls = {
inlay_hints = true,
},
vtsls = {},
},
}
local t2 = {
servers = {
gopls = {},
lua_ls = {
inlay_hints = false,
},
},
}
local t3 = vim.tbl_deep_extend("force", t1, t2)
print(vim.inspect(t1))
print(vim.inspect(t2))
print(vim.inspect(t3))
-- t1
{
servers = {
lua_ls = {
inlay_hints = true
},
vtsls = {}
}
}
-- t2
{
servers = {
gopls = {},
lua_ls = {
inlay_hints = false
}
}
}
-- t3
{
servers = {
gopls = {},
lua_ls = {
inlay_hints = false
},
vtsls = {}
}
}
If using a plugin that uses vim.g
for config, you can still use opts
for merging configs, then have:
config = function(opts)
vim.g.my_plugin_config = opts
end
in your lazy plugin spec.
Test out looping through files in a directory and using
vim.tbl_deep_extend
to merge them, e.g. some lsp configs and formatter setup (usingvim.list_extend
).If this works, then I can use
vim.g
to store configs for plugins and also mirror theopts
merging from lazy.nvim to potentially be used with vim plug.