diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-12-30 16:12:46 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-12-30 16:12:46 +0800 |
commit | a48139e5dd7e7a6e9e3bd00a41334a1e66d1a227 (patch) | |
tree | b363a6a733280839bb3d2170e26668143106ee9f | |
parent | f0f9a4ea4509dfb764a5dfebd5e86e679c8f4b03 (diff) | |
download | lua-language-server-a48139e5dd7e7a6e9e3bd00a41334a1e66d1a227.zip |
update
-rw-r--r-- | script/core/hover/description.lua | 8 | ||||
-rw-r--r-- | script/provider/provider.lua | 4 | ||||
-rw-r--r-- | script/service/service.lua | 11 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 18 |
4 files changed, 29 insertions, 12 deletions
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index 59605f0d..c5a42a32 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -11,8 +11,8 @@ local guide = require 'parser.guide' local noder = require 'core.noder' local rpath = require 'workspace.require-path' -local function collectRequire(mode, literal) - local rootPath = ws.rootPath or '' +local function collectRequire(mode, literal, uri) + local rootPath = ws.getRootUri(uri) or '' local result, searchers if mode == 'require' then result, searchers = rpath.findUrisByRequirePath(literal) @@ -57,7 +57,7 @@ local function asStringInRequire(source, literal) if libName == 'require' or libName == 'dofile' or libName == 'loadfile' then - return collectRequire(libName, literal) + return collectRequire(libName, literal, guide.getUri(source)) end end end @@ -157,7 +157,7 @@ local function tryDocModule(source) if not source.module then return end - return collectRequire('require', source.module) + return collectRequire('require', source.module, guide.getUri(source)) end local function buildEnumChunk(docType, name) diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 51a10b19..23dd6e11 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -258,7 +258,7 @@ m.register 'textDocument/hover' { local doc = params.textDocument local uri = files.getRealUri(doc.uri) if not workspace.isReady() then - local count, max = workspace.getLoadProcess() + local count, max = workspace.getLoadingProcess(uri) return { contents = { value = lang.script('HOVER_WS_LOADING', count, max), @@ -471,7 +471,7 @@ m.register 'textDocument/completion' { function (params) local uri = files.getRealUri(params.textDocument.uri) if not workspace.isReady() then - local count, max = workspace.getLoadProcess() + local count, max = workspace.getLoadingProcess(uri) return { { label = lang.script('HOVER_WS_LOADING', count, max),textEdit = { diff --git a/script/service/service.lua b/script/service/service.lua index 76478394..4594b9aa 100644 --- a/script/service/service.lua +++ b/script/service/service.lua @@ -11,6 +11,7 @@ local lang = require 'language' local ws = require 'workspace' local time = require 'bee.time' local fw = require 'filewatch' +local furi = require 'file-uri' local m = {} m.type = 'service' @@ -189,8 +190,14 @@ function m.reportStatus() else info.text = '😺Lua' end + + local roots = {} + for i, scp in ipairs(ws.folders) do + roots[i] = furi.decode(scp.uri) + end + info.tooltip = lang.script('WINDOW_LUA_STATUS', { - ws = ws.rootPath or '', + ws = table.concat(roots, '/'), ast = files.astCount, max = files.fileCount, mem = collectgarbage('count') / 1000, @@ -226,8 +233,6 @@ function m.start() require 'provider' m.startTimer() - - ws.reload() end return m diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index 8e26b1df..4d904773 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -17,6 +17,8 @@ local loading = require 'workspace.loading' ---@class workspace local m = {} m.type = 'workspace' +---@type scope[] +m.folders = {} function m.initRoot(uri) m.rootUri = uri @@ -33,7 +35,13 @@ function m.create(uri) log.info('Workspace create: ', uri) local path = m.normalize(furi.decode(uri)) fw.watch(path) - scope.createFolder(uri) + local scp = scope.createFolder(uri) + m.folders[#m.folders+1] = scp +end + +function m.getRootUri(uri) + local scp = m.getScope(uri) + return scp.uri end local globInteferFace = { @@ -228,6 +236,7 @@ function m.awaitPreload(scp) scp:set('watchers', watchers) local ld <close> = loading.create(scp) + scp:set('loading', ld) log.info('Preload start:', scp.uri) @@ -443,8 +452,11 @@ function m.isReady(uri) return scp:get('ready') == true end -function m.getLoadProcess() - return m.fileLoaded, m.fileFound +function m.getLoadingProcess(uri) + local scp = m.getScope(uri) + ---@type workspace.loading + local ld = scp:get 'loading' + return ld.read, ld.max end files.watch(function (ev, uri) ---@async |