diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-11-24 17:38:13 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-11-24 17:38:13 +0800 |
commit | 94c1a8c91132d2b4345e68eec7f9bfcafd7485d9 (patch) | |
tree | eb988a23b85d54a625148aba2d2967fa504de593 /script/core/completion | |
parent | 9143322ddf72876f3c89349e37a62cdf20cf3b65 (diff) | |
download | lua-language-server-94c1a8c91132d2b4345e68eec7f9bfcafd7485d9.zip |
postfix add `insert`, `remove`, `concat`
Diffstat (limited to 'script/core/completion')
-rw-r--r-- | script/core/completion/postfix.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/script/core/completion/postfix.lua b/script/core/completion/postfix.lua index d1959fd0..9ad20965 100644 --- a/script/core/completion/postfix.lua +++ b/script/core/completion/postfix.lua @@ -133,6 +133,60 @@ register 'xpcall' { end } +register 'insert' { + function (state, source, callback) + if source.type ~= 'getglobal' + and source.type ~= 'getfield' + and source.type ~= 'getmethod' + and source.type ~= 'getindex' + and source.type ~= 'getlocal' + and source.type ~= 'call' + and source.type ~= 'table' then + return + end + local subber = subString(state) + callback(string.format('table.insert(%s, $0)' + , subber(source.start + 1, source.finish) + )) + end +} + +register 'remove' { + function (state, source, callback) + if source.type ~= 'getglobal' + and source.type ~= 'getfield' + and source.type ~= 'getmethod' + and source.type ~= 'getindex' + and source.type ~= 'getlocal' + and source.type ~= 'call' + and source.type ~= 'table' then + return + end + local subber = subString(state) + callback(string.format('table.remove(%s, $0)' + , subber(source.start + 1, source.finish) + )) + end +} + +register 'concat' { + function (state, source, callback) + if source.type ~= 'getglobal' + and source.type ~= 'getfield' + and source.type ~= 'getmethod' + and source.type ~= 'getindex' + and source.type ~= 'getlocal' + and source.type ~= 'call' + and source.type ~= 'table' then + return + end + local subber = subString(state) + callback(string.format('table.concat(%s, $0)' + , subber(source.start + 1, source.finish) + )) + end +} + register '++' { function (state, source, callback) if source.type ~= 'getglobal' @@ -173,6 +227,7 @@ local accepts = { ['getindex'] = true, ['getmethod'] = true, ['call'] = true, + ['table'] = true, } local function checkPostFix(state, word, wordPosition, position, results) |