summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-21 14:32:14 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-21 14:32:14 +0800
commit789a3e93e7d403daf8e508606a1b946409658855 (patch)
tree5047b1433f3b2d7281ef2841658dd0836369d583 /server/src
parente50a8947ab1c6016e3763e76e0c3bedfa1b9c002 (diff)
downloadlua-language-server-789a3e93e7d403daf8e508606a1b946409658855.zip
require 文本的hover
Diffstat (limited to 'server/src')
-rw-r--r--server/src/matcher/hover.lua17
-rw-r--r--server/src/method/textDocument/hover.lua2
-rw-r--r--server/src/workspace.lua6
3 files changed, 23 insertions, 2 deletions
diff --git a/server/src/matcher/hover.lua b/server/src/matcher/hover.lua
index bfaead9a..9a556104 100644
--- a/server/src/matcher/hover.lua
+++ b/server/src/matcher/hover.lua
@@ -364,11 +364,26 @@ local function getValueHover(name, valueType, result, source, lib)
]]):format(text, tip)
end
-return function (result, source)
+local function getStringHover(result, lsp)
+ if not result.uri then
+ return nil
+ end
+ if not lsp or not lsp.workspace then
+ return nil
+ end
+ local path = lsp.workspace:relativePathByUri(result.uri)
+ return ('[%s](%s)'):format(path:string(), result.uri)
+end
+
+return function (result, source, lsp)
if not result.value then
return
end
+ if result.type == 'string' then
+ return getStringHover(result, lsp)
+ end
+
local lib, fullKey, oo = findLib(result)
local valueType = lib and lib.type or result.value.type or 'nil'
local name = fullKey or buildValueName(result, source)
diff --git a/server/src/method/textDocument/hover.lua b/server/src/method/textDocument/hover.lua
index 33b90c7d..cf6c4aa4 100644
--- a/server/src/method/textDocument/hover.lua
+++ b/server/src/method/textDocument/hover.lua
@@ -14,7 +14,7 @@ return function (lsp, params)
return nil
end
- local text = matcher.hover(result, source)
+ local text = matcher.hover(result, source, lsp)
if not text then
return nil
end
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index c2478e40..655dd873 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -175,6 +175,12 @@ function mt:reset()
self.lsp:reCompile()
end
+function mt:relativePathByUri(uri)
+ local path = uriDecode(uri)
+ local relate = fs.relative(path, self.root)
+ return relate
+end
+
return function (lsp, name, uri)
local workspace = setmetatable({
lsp = lsp,