summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-21 17:17:16 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-21 17:17:16 +0800
commit9998cbabf7e8fc795c45ad9c8b91c243e87524a5 (patch)
tree14cb2a84b63864ee767ff6007afb78843a997872
parentaeac4c08a5a6ed1c832ca62aad0190e660887abe (diff)
downloadlua-language-server-9998cbabf7e8fc795c45ad9c8b91c243e87524a5.zip
可以显示参数提示了
-rw-r--r--server/src/method/textDocument/signatureHelp.lua60
1 files changed, 26 insertions, 34 deletions
diff --git a/server/src/method/textDocument/signatureHelp.lua b/server/src/method/textDocument/signatureHelp.lua
index 0fb7fd10..763e7a15 100644
--- a/server/src/method/textDocument/signatureHelp.lua
+++ b/server/src/method/textDocument/signatureHelp.lua
@@ -4,45 +4,37 @@ return function (lsp, params)
local uri = params.textDocument.uri
local vm, lines = lsp:loadVM(uri)
if not vm then
- return {}
+ return
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- do return end
- return {
- activeSignature = 0,
- activeParameter = 1,
- signatures = {
- {
- label = 'xxxx(a, b, c)',
- documentation = {
- kind = 'markdown',
- value = '函数说明',
- },
- parameters = {
- {
- label = 'a',
- documentation = {
- kind = 'markdown',
- value = '参数a说明',
- },
- },
- {
- label = 'b',
- documentation = {
- kind = 'markdown',
- value = '参数b说明',
- },
- },
- {
- label = 'c',
- documentation = {
- kind = 'markdown',
- value = '参数c说明',
- },
- },
+ local hovers = matcher.signature(vm, position)
+ if not hovers then
+ return
+ end
+
+ local signatures = {}
+ for i, hover in ipairs(hovers) do
+ signatures[i] = {
+ label = hover.label,
+ documentation = {
+ kind = 'markdown',
+ value = hover.description,
+ },
+ parameters = {
+ {
+ label = hover.argLabel,
},
},
}
+ end
+
+ local response = {
+ signatures = signatures,
+ activeSignature = #signatures - 1,
}
+
+ log.debug(table.dump(response))
+
+ return response
end