diff options
Diffstat (limited to 'script/method/completionItem')
-rw-r--r-- | script/method/completionItem/resolve.lua | 27 |
1 files changed, 27 insertions, 0 deletions
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 |