diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-22 14:05:52 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-22 14:05:52 +0800 |
commit | 67ae2be22b43fec1c7bab1044842951eba84d37d (patch) | |
tree | a21d6a0f480f98e5d58c80d476bd53391d53a0eb /server-beta/src/core/hover | |
parent | c29bbc645b931aa6fb6bff6b0e3da432eedd8ecd (diff) | |
download | lua-language-server-67ae2be22b43fec1c7bab1044842951eba84d37d.zip |
更新 hover
Diffstat (limited to 'server-beta/src/core/hover')
-rw-r--r-- | server-beta/src/core/hover/label.lua | 5 | ||||
-rw-r--r-- | server-beta/src/core/hover/return.lua | 20 |
2 files changed, 24 insertions, 1 deletions
diff --git a/server-beta/src/core/hover/label.lua b/server-beta/src/core/hover/label.lua index a9e7ba13..da8a0c84 100644 --- a/server-beta/src/core/hover/label.lua +++ b/server-beta/src/core/hover/label.lua @@ -6,7 +6,10 @@ local function asFunction(source) local name = buildName(source) local arg = buildArg(source) local rtn = buildReturn(source) - return ('function %s(%s)'):format(name, arg) + local lines = {} + lines[1] = ('function %s(%s)'):format(name, arg) + lines[2] = rtn + return table.concat(lines, '\n') end return function (source) diff --git a/server-beta/src/core/hover/return.lua b/server-beta/src/core/hover/return.lua index dbc3df85..c22626a6 100644 --- a/server-beta/src/core/hover/return.lua +++ b/server-beta/src/core/hover/return.lua @@ -5,6 +5,26 @@ local function asFunction(source) if not source.returns then return nil end + local returns = {} + for _, rtn in ipairs(source.returns) do + for i = 1, #rtn do + local values = vm.getValue(rtn[i]) + returns[#returns+1] = values + end + break + end + if #returns == 0 then + return nil + end + local lines = {} + for i = 1, #returns do + if i == 1 then + lines[i] = (' -> %s'):format(vm.viewType(returns[i])) + else + lines[i] = ('% 3d. %s'):format(i, returns[i]) + end + end + return table.concat(lines, '\n') end return function (source) |