From a782eb79202e29326b96fab7cd7591ba881a7778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 23 Jun 2020 16:12:29 +0800 Subject: =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9D=97=E5=8F=82=E8=80=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/method/completionItem/resolve.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 script/method/completionItem/resolve.lua (limited to 'script/method/completionItem') diff --git a/script/method/completionItem/resolve.lua b/script/method/completionItem/resolve.lua new file mode 100644 index 00000000..9909166a --- /dev/null +++ b/script/method/completionItem/resolve.lua @@ -0,0 +1,27 @@ +return function (lsp, item) + if not item.data then + return item + end + local offset = item.data.offset + local uri = item.data.uri + local _, lines, text = lsp:getVM(uri) + if not lines then + return item + end + local row = lines:rowcol(offset) + local firstRow = lines[row] + local lastRow = lines[math.min(row + 5, #lines)] + local snip = text:sub(firstRow.start, lastRow.finish) + local document = ([[ +%s +------------ +```lua +%s +``` +]]):format(item.documentation and item.documentation.value or '', snip) + item.documentation = { + kind = 'markdown', + value = document, + } + return item +end -- cgit v1.2.3