2022-07-03 16:52:15 +08:00
|
|
|
--=============================================================================
|
|
|
|
-- opt.lua --- The global option of spacevim
|
2023-03-26 13:44:47 +08:00
|
|
|
-- Copyright (c) 2016-2023 Wang Shidong & Contributors
|
2022-07-03 16:52:15 +08:00
|
|
|
-- Author: Wang Shidong < wsdjeg@outlook.com >
|
|
|
|
-- URL: https://spacevim.org
|
|
|
|
-- License: GPLv3
|
|
|
|
--=============================================================================
|
2021-08-17 22:54:06 +08:00
|
|
|
local M = {}
|
2022-07-03 16:52:15 +08:00
|
|
|
|
2021-08-17 22:54:06 +08:00
|
|
|
local sp = require('spacevim')
|
2019-05-31 21:45:09 +08:00
|
|
|
|
2021-08-17 22:54:06 +08:00
|
|
|
local mt = {
|
|
|
|
-- this is call when we use opt.xxxx = xxx
|
|
|
|
__newindex = function(table, key, value)
|
|
|
|
if vim.g ~= nil then
|
|
|
|
vim.g['spacevim_' .. key] = value
|
|
|
|
else
|
|
|
|
end
|
2019-05-31 21:45:09 +08:00
|
|
|
|
2021-08-17 22:54:06 +08:00
|
|
|
end,
|
|
|
|
-- this is call when we use opt.xxxx
|
|
|
|
__index = function(table, key)
|
|
|
|
if vim.g ~= nil then
|
|
|
|
return vim.g['spacevim_' .. key] or nil
|
|
|
|
else
|
|
|
|
return sp.eval('get(g:, "spacevim_' .. key .. '", v:null)')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
setmetatable(M, mt)
|
2019-05-31 21:45:09 +08:00
|
|
|
|
2021-08-17 22:54:06 +08:00
|
|
|
return M
|