diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-15 14:07:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-15 14:07:14 +0800 |
commit | a4bff71503fcf5d5a1bff8dc3ce209050afea86c (patch) | |
tree | 06fe335cfdfc7dbb24f958d63fd9c99a06843704 | |
parent | 8e9d309bf2a3b3e3f4530acb2cbaa3cdd6869cee (diff) | |
download | lua-language-server-a4bff71503fcf5d5a1bff8dc3ce209050afea86c.zip |
_G的处理
-rw-r--r-- | server/src/method/initialize.lua | 2 | ||||
-rw-r--r-- | server/src/vm/global.lua | 7 | ||||
-rw-r--r-- | server/src/vm/value.lua | 4 | ||||
-rw-r--r-- | server/test/definition/set.lua | 5 | ||||
-rw-r--r-- | server/test/diagnostics/init.lua | 4 |
5 files changed, 18 insertions, 4 deletions
diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index ba183c5e..e236617c 100644 --- a/server/src/method/initialize.lua +++ b/server/src/method/initialize.lua @@ -22,7 +22,7 @@ return function (lsp) -- 支持“重命名” renameProvider = true, -- 支持“大纲” - documentSymbolProvider = true, + --documentSymbolProvider = true, -- 支持“签名帮助” signatureHelpProvider = { triggerCharacters = { '(', ',' }, diff --git a/server/src/vm/global.lua b/server/src/vm/global.lua index bb506ce9..b1b32505 100644 --- a/server/src/vm/global.lua +++ b/server/src/vm/global.lua @@ -13,9 +13,14 @@ return function (lsp) global:rawSet(name, value) end end + + local _G = global:getChild '_G' + global:eachChild(function (k, v) + _G:setChild(k, v) + end) end if lsp then lsp.globalValue = global end - return global + return global:rawGet('_G') end diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index 44e9d1e4..60f0c663 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -151,6 +151,10 @@ function mt:getChild(index, source, mark) return method:getChild(index, source, mark) end +function mt:bindChild(other) + self._child = other._child +end + function mt:setMetaTable(metatable) self._meta = metatable end diff --git a/server/test/definition/set.lua b/server/test/definition/set.lua index 82dc4828..eb899fc9 100644 --- a/server/test/definition/set.lua +++ b/server/test/definition/set.lua @@ -38,3 +38,8 @@ else end print(<?x?>) ]] + +TEST [[ +_G.<!x!> = 1 +print(<?x?>) +]] diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua index 8c2f4dba..4af8f975 100644 --- a/server/test/diagnostics/init.lua +++ b/server/test/diagnostics/init.lua @@ -119,12 +119,12 @@ local _ENV ]] TEST [[ -print(_G) +print() <!('string')!>:sub(1, 1) ]] TEST [[ -print(_G) +print() ('string') ]] |