diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 21:55:41 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-20 21:55:41 +0800 |
commit | c63b2e404d8d2bb984afe3678a5ba2b2836380cc (patch) | |
tree | a70661effacc7a29caa8d49583673ac4be2faaf5 /script/method/textDocument/hover.lua | |
parent | 85c5a4210e4447422cd5677369ae740ed65725a0 (diff) | |
download | lua-language-server-c63b2e404d8d2bb984afe3678a5ba2b2836380cc.zip |
remove the old version
Diffstat (limited to 'script/method/textDocument/hover.lua')
-rw-r--r-- | script/method/textDocument/hover.lua | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/script/method/textDocument/hover.lua b/script/method/textDocument/hover.lua deleted file mode 100644 index a456bb0a..00000000 --- a/script/method/textDocument/hover.lua +++ /dev/null @@ -1,69 +0,0 @@ -local core = require 'core' -local config = require 'config' - -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 -return function (lsp, params) - if not config.config.hover.enable then - return nil - end - local uri = params.textDocument.uri - local vm, lines = lsp:loadVM(uri) - if not vm then - return nil - end - -- lua是从1开始的,因此都要+1 - local position = lines:positionAsChar(params.position.line + 1, params.position.character) - - local source = core.findSource(vm, position) - if not source then - return nil - end - - local hover = core.hover(source, lsp) - if not hover then - return nil - end - - local text = ([[ -```lua -%s -``` -```lua -%s -``` -%s -```lua -%s -``` -%s -]]):format(hover.label or '', hover.overloads or '', hover.description or '', hover.enum or '', hover.doc or '') - - local response = { - contents = { - value = text:gsub("```lua\n\n```", ""), - kind = 'markdown', - }, - range = hover.range and convertRange(lines, hover.range), - } - - return response -end |