diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-09-28 02:43:52 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-09-28 02:43:52 +0800 |
commit | 274cd6b326ca6be0da65ebde79f8c48c83bc406b (patch) | |
tree | bc20cc1cc5a1be2645e18db35a4c1ef0a71c0354 /script-beta/core/hover/description.lua | |
parent | c352af7a59b14f60ea5aca7bddfbc891068b4cb0 (diff) | |
download | lua-language-server-274cd6b326ca6be0da65ebde79f8c48c83bc406b.zip |
hover也显示推测的搜索路径
Diffstat (limited to 'script-beta/core/hover/description.lua')
-rw-r--r-- | script-beta/core/hover/description.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/script-beta/core/hover/description.lua b/script-beta/core/hover/description.lua index 63c5afae..af6ad608 100644 --- a/script-beta/core/hover/description.lua +++ b/script-beta/core/hover/description.lua @@ -7,6 +7,7 @@ local markdown = require 'provider.markdown' local config = require 'config' local client = require 'provider.client' local lang = require 'language' +local platform = require 'bee.platform' local function asString(source) local literal = guide.getLiteral(source) @@ -15,7 +16,7 @@ local function asString(source) end local parent = source.parent if parent and parent.type == 'callargs' then - local result + local result, searchers local call = parent.parent local func = call.node local lib = vm.getLibrary(func) @@ -23,20 +24,27 @@ local function asString(source) return end if lib.name == 'require' then - result = ws.findUrisByRequirePath(literal) + result, searchers = ws.findUrisByRequirePath(literal) elseif lib.name == 'dofile' or lib.name == 'loadfile' then result = ws.findUrisByFilePath(literal) end if result and #result > 0 then for i, uri in ipairs(result) do + local searcher = searchers and furi.decode(searchers[uri]) uri = files.getOriginUri(uri) local path = furi.decode(uri) if files.eq(path:sub(1, #ws.path), ws.path) then path = path:sub(#ws.path + 1) end path = path:gsub('^[/\\]*', '') - result[i] = ('* [%s](%s)'):format(path, uri) + if searcher then + searcher = ws.normalize(searcher) + searcher = searcher:sub(#ws.path + 1) + result[i] = ('* [%s](%s) (假设搜索路径包含 `%s`)'):format(path, uri, searcher) + else + result[i] = ('* [%s](%s)'):format(path, uri) + end end table.sort(result) return table.concat(result, '\n') |