summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/hover.lua19
-rw-r--r--server/src/core/hover_name.lua2
-rw-r--r--server/src/core/value.lua27
3 files changed, 38 insertions, 10 deletions
diff --git a/server/src/core/hover.lua b/server/src/core/hover.lua
index 7ee8c5bf..dbe9a21d 100644
--- a/server/src/core/hover.lua
+++ b/server/src/core/hover.lua
@@ -346,7 +346,13 @@ local function getStringHover(result, lsp)
}
end
-return function (result, source, lsp, select)
+local function hoverAsValue(result, source, lsp, select)
+ if result:getType() == 'string' then
+ return getStringHover(result, lsp)
+ end
+end
+
+local function hoverAsVar(result, source, lsp, select)
if not result.value then
return
end
@@ -355,9 +361,6 @@ return function (result, source, lsp, select)
return
end
- if result.type == 'string' then
- return getStringHover(result, lsp)
- end
if result.type ~= 'local' and result.type ~= 'field' then
return
@@ -389,3 +392,11 @@ return function (result, source, lsp, select)
hover.name = name
return hover
end
+
+return function (result, source, lsp, select)
+ if result.type == 'value' then
+ return hoverAsValue(result, source, lsp, select)
+ else
+ return hoverAsVar(result, source, lsp, select)
+ end
+end
diff --git a/server/src/core/hover_name.lua b/server/src/core/hover_name.lua
index affc33f3..5e358820 100644
--- a/server/src/core/hover_name.lua
+++ b/server/src/core/hover_name.lua
@@ -16,7 +16,7 @@ return function (result, source)
key = ('%q'):format(declarat[1])
elseif declarat.type == 'number' or declarat.type == 'boolean' then
key = tostring(declarat[1])
- elseif func.type == 'function' then
+ elseif func:getType() == 'function' then
key = ''
elseif type(result.key) == 'string' then
key = result.key
diff --git a/server/src/core/value.lua b/server/src/core/value.lua
index 0cab8516..1d8ed567 100644
--- a/server/src/core/value.lua
+++ b/server/src/core/value.lua
@@ -164,14 +164,31 @@ function mt:eachField(callback)
end
function mt:getDeclarat()
- return self:eachInfo(function (info)
- if info.type == 'local'
- or info.type == 'set'
- or info.type == 'return'
- then
+ local declarat = self:eachInfo(function (info)
+ if info.type == 'local' then
return info.source
end
end)
+ if declarat then
+ return declarat
+ end
+ local declarat = self:eachInfo(function (info)
+ if info.type == 'return' then
+ return info.source
+ end
+ end)
+ if declarat then
+ return declarat
+ end
+ local declarat = self:eachInfo(function (info)
+ if info.type == 'set' then
+ return info.source
+ end
+ end)
+ if declarat then
+ return declarat
+ end
+ return nil
end
function mt:addInfo(tp, source, var)