summaryrefslogtreecommitdiff
path: root/script/core/completion/postfix.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-23 22:44:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-23 22:44:35 +0800
commitccc724254cce1b0a8577424051735f9b722bd6f2 (patch)
tree22cce8462c027fd36918aea357385dd475e9d2e2 /script/core/completion/postfix.lua
parent87c9daacef9600e0fd681716c0b2e21898829df7 (diff)
downloadlua-language-server-ccc724254cce1b0a8577424051735f9b722bd6f2.zip
xpcall
Diffstat (limited to 'script/core/completion/postfix.lua')
-rw-r--r--script/core/completion/postfix.lua24
1 files changed, 23 insertions, 1 deletions
diff --git a/script/core/completion/postfix.lua b/script/core/completion/postfix.lua
index 16bada87..ee4df4b4 100644
--- a/script/core/completion/postfix.lua
+++ b/script/core/completion/postfix.lua
@@ -30,7 +30,29 @@ register 'pcall' {
))
end
else
- callback(string.format('pcall(%s)'
+ callback(string.format('pcall(%s$1)$0'
+ , subber(source.start + 1, source.finish)
+ ))
+ end
+ end
+}
+
+register 'xpcall' {
+ function (state, source, callback)
+ local subber = subString(state)
+ if source.type == 'call' then
+ if source.args and #source.args > 0 then
+ callback(string.format('xpcall(%s, ${1:debug.traceback}, %s)$0'
+ , subber(source.node.start + 1, source.node.finish)
+ , subber(source.args[1].start + 1, source.args[#source.args].finish)
+ ))
+ else
+ callback(string.format('xpcall(%s, ${1:debug.traceback})$0'
+ , subber(source.node.start + 1, source.node.finish)
+ ))
+ end
+ else
+ callback(string.format('xpcall(%s, ${1:debug.traceback}$2)$0'
, subber(source.start + 1, source.finish)
))
end