diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 16:50:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 16:50:01 +0800 |
commit | 3c5ff2671305041d03cde8dafb05d4aed0cc0a65 (patch) | |
tree | 0f058a92500c7abef99fab007dc30d80107795b6 /server/src/method | |
parent | bc0ab7b1fa924076a549cdcaaf3e90a6ef67600f (diff) | |
download | lua-language-server-3c5ff2671305041d03cde8dafb05d4aed0cc0a65.zip |
找当前参数
Diffstat (limited to 'server/src/method')
-rw-r--r-- | server/src/method/init.lua | 1 | ||||
-rw-r--r-- | server/src/method/initialize.lua | 4 | ||||
-rw-r--r-- | server/src/method/textDocument/signatureHelp.lua | 48 |
3 files changed, 53 insertions, 0 deletions
diff --git a/server/src/method/init.lua b/server/src/method/init.lua index 22c58289..ea7fa05a 100644 --- a/server/src/method/init.lua +++ b/server/src/method/init.lua @@ -18,6 +18,7 @@ init 'textDocument/implementation' init 'textDocument/publishDiagnostics' init 'textDocument/rename' init 'textDocument/references' +init 'textDocument/signatureHelp' init 'workspace/didChangeWatchedFiles' init 'workspace/didChangeWorkspaceFolders' diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index 05a1bb49..4bc3ff2e 100644 --- a/server/src/method/initialize.lua +++ b/server/src/method/initialize.lua @@ -12,6 +12,10 @@ return function (lsp) referencesProvider = true, -- 支持“重命名” renameProvider = true, + -- 支持“签名帮助” + signatureHelpProvider = { + triggerCharacters = { '(', ',' }, + }, -- 文本同步方式 textDocumentSync = { -- 打开关闭文本时通知 diff --git a/server/src/method/textDocument/signatureHelp.lua b/server/src/method/textDocument/signatureHelp.lua new file mode 100644 index 00000000..0fb7fd10 --- /dev/null +++ b/server/src/method/textDocument/signatureHelp.lua @@ -0,0 +1,48 @@ +local matcher = require 'matcher' + +return function (lsp, params) + local uri = params.textDocument.uri + local vm, lines = lsp:loadVM(uri) + if not vm then + 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说明', + }, + }, + }, + }, + } + } +end |