summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-18 02:48:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-18 02:48:43 +0800
commitf99a3cd8dea446852d8282319d620704eb0e6094 (patch)
tree6521dc0c0bec4fcdd9d060baacc27812ce2afa53 /script
parent256d5de895fd5f74467f2eefe35c96131c1adf15 (diff)
downloadlua-language-server-f99a3cd8dea446852d8282319d620704eb0e6094.zip
cleanup
Diffstat (limited to 'script')
-rw-r--r--script/config/config.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/script/config/config.lua b/script/config/config.lua
index 8dd7dc3e..f8d9e985 100644
--- a/script/config/config.lua
+++ b/script/config/config.lua
@@ -112,6 +112,31 @@ function m.add(uri, key, value)
return false
end
+function m.remove(uri, key, value)
+ local unit = template[key]
+ if not unit then
+ return false
+ end
+ local list = m.getRaw(uri, key)
+ if type(list) ~= 'table' then
+ return false
+ end
+ local copyed = {}
+ for i, v in ipairs(list) do
+ if not util.equal(v, value) then
+ copyed[i] = v
+ end
+ end
+ local oldValue = m.get(uri, key)
+ m.set(uri, key, copyed)
+ local newValue = m.get(uri, key)
+ if not util.equal(oldValue, newValue) then
+ m.event(uri, key, newValue, oldValue)
+ return true
+ end
+ return false
+end
+
function m.prop(uri, key, prop, value)
local unit = template[key]
if not unit then