summaryrefslogtreecommitdiff
path: root/script/method/textDocument
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-01 14:01:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-01 14:01:32 +0800
commit85e12909c541c00b5947db5f91dbbba903d8339c (patch)
treed17dea4b9d9f25e7c826e4372067027d855ea574 /script/method/textDocument
parent3c6093968f6b9c73628763b646d97a8870ffeb12 (diff)
downloadlua-language-server-85e12909c541c00b5947db5f91dbbba903d8339c.zip
字符串详情
Diffstat (limited to 'script/method/textDocument')
-rw-r--r--script/method/textDocument/hover.lua20
1 files changed, 19 insertions, 1 deletions
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