summaryrefslogtreecommitdiff
path: root/server/src/matcher/hover.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-12 21:15:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-12 21:15:27 +0800
commitd76d63f7063376852ee9c8ea6795abde09149851 (patch)
tree5067140e9d592e5e401fe448186592026e59a133 /server/src/matcher/hover.lua
parent3ce89009f9e37193a00aa3eefb09f46eaff409c7 (diff)
downloadlua-language-server-d76d63f7063376852ee9c8ea6795abde09149851.zip
非函数的hover
Diffstat (limited to 'server/src/matcher/hover.lua')
-rw-r--r--server/src/matcher/hover.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/src/matcher/hover.lua b/server/src/matcher/hover.lua
index 750cf778..d4d9d04b 100644
--- a/server/src/matcher/hover.lua
+++ b/server/src/matcher/hover.lua
@@ -270,9 +270,41 @@ local function buildValueFunctionHover(result, source)
]]):format(title)
end
+local function buildValueSimpleHover(result, source)
+ local type = result.value.type
+ if type == 'nil' then
+ type = 'any'
+ end
+ local resType = result.type
+ if resType == 'field' then
+ local field = result
+ local stack = 0
+ while field.parent do
+ field = field.parent
+ stack = stack + 1
+ end
+ if field.value.ENV then
+ if stack > 1 then
+ resType = 'global field'
+ else
+ resType = 'global'
+ end
+ else
+ resType = 'local field'
+ end
+ end
+ return ([[
+```lua
+%s: %s
+```
+]]):format(resType, type)
+end
+
local function getValueHover(result, source)
if result.value.type == 'function' then
return buildValueFunctionHover(result, source)
+ else
+ return buildValueSimpleHover(result, source)
end
end