diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-07-01 14:01:32 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-07-01 14:01:32 +0800 |
commit | 85e12909c541c00b5947db5f91dbbba903d8339c (patch) | |
tree | d17dea4b9d9f25e7c826e4372067027d855ea574 /script/method | |
parent | 3c6093968f6b9c73628763b646d97a8870ffeb12 (diff) | |
download | lua-language-server-85e12909c541c00b5947db5f91dbbba903d8339c.zip |
字符串详情
Diffstat (limited to 'script/method')
-rw-r--r-- | script/method/completionItem/resolve.lua | 1 | ||||
-rw-r--r-- | script/method/textDocument/hover.lua | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/script/method/completionItem/resolve.lua b/script/method/completionItem/resolve.lua index 9909166a..7d18288e 100644 --- a/script/method/completionItem/resolve.lua +++ b/script/method/completionItem/resolve.lua @@ -14,6 +14,7 @@ return function (lsp, item) local snip = text:sub(firstRow.start, lastRow.finish) local document = ([[ %s + ------------ ```lua %s diff --git a/script/method/textDocument/hover.lua b/script/method/textDocument/hover.lua index 2e909dc1..4ae80040 100644 --- a/script/method/textDocument/hover.lua +++ b/script/method/textDocument/hover.lua @@ -1,5 +1,22 @@ local core = require 'core' +local function convertRange(lines, range) + local start_row, start_col = lines:rowcol(range.start) + local finish_row, finish_col = lines:rowcol(range.finish) + local result = { + start = { + line = start_row - 1, + character = start_col - 1, + }, + ['end'] = { + line = finish_row - 1, + -- 这里不用-1,因为前端期待的是匹配完成后的位置 + character = finish_col, + }, + } + return result +end + --- @param lsp LSP --- @param params table --- @return table @@ -40,7 +57,8 @@ return function (lsp, params) contents = { value = text:gsub("```lua\n\n```", ""), kind = 'markdown', - } + }, + range = hover.range and convertRange(lines, hover.range), } return response |